inGoogleITrust
inGoogleITrust

Reputation: 1

data access problem in jsf

I have the following class-files:

class RowData {
...
  ArrayList<String> valueMap;
...
}

class Bean {
...
  public List<RowData> getData() {
  ...
  }
}

jsf code snippet:

...
<h:form>
  <rich:dataTable id="overviewTable" value="#{bean.getData()}" var="row">

    <c:forEach items="#{row.valueMap}" var="r">

      <rich:column>
        <h:outputText value="#{r}" />
      </rich:column>
    </c:forEach>
  </rich:dataTable> 
</h:form>
...

Unfortunately, the table doesn't appear. What's wrong? The page doesn't show an error or something, the table is just not there (in this version I skipped all the getter and setter...). When I want to access other data from the bean, it works, so the whole setup should be ok.

Upvotes: 0

Views: 259

Answers (2)

Jose Diaz
Jose Diaz

Reputation: 5398

Use value="#{bean.data}" instead. Remember, you're using E.L and it is assumed that you're referencing a java bean property named data through the getter method getData(). The data property might not exists but the method named should definitely be named like this.

Also, in order to use the items="#{row.valueMap}" idiom, you must have a getValueMap() method present in your bean class.

Do you get the idea?

Upvotes: 0

dov.amir
dov.amir

Reputation: 11637

you should not write the "get" and the "()" in "getData()", also, I dont think you need the "foreach" in a datatable

look at this example from http://richfaces-showcase.appspot.com/richfaces/component-sample.jsf?demo=dataTable&sample=tableStyling&skin=blueSky

<rich:dataTable value="#{carsBean.allInventoryItems}" var="car"
        id="table" rows="20" rowClasses="odd-row, even-row"
        styleClass="stable">
        <rich:column accept="#{carsFiteringBean.acceptVendor}">
            <f:facet name="header">
                <h:outputText value="Vendor " />
            </f:facet>
            <h:outputText value="#{car.vendor}" />
        </rich:column>
        <rich:column>
            <f:facet name="header">
                <h:outputText value="Model" />
            </f:facet>
            <h:outputText value="#{car.model}" />
        </rich:column>
        <rich:column>
            <f:facet name="header">
                <h:outputText value="Price" />
            </f:facet>
            <h:outputText value="#{car.price}" />
        </rich:column>
        <rich:column filter="#{carsFilteringBean.mileageFilterImpl}">
            <f:facet name="header">
                <h:outputText value="Mileage" />
            </f:facet>
            <h:outputText value="#{car.mileage}" />
        </rich:column>
        <rich:column>
            <f:facet name="header">
                <h:outputText value="VIN " />
            </f:facet>
            <h:outputText value="#{car.vin}" />
        </rich:column>
    </rich:dataTable>
</h:form>

Upvotes: 2

Related Questions