h:datatable not populated
This is a related (and or follow up) issue to :
Event Function called before Setter
So Given i have :
<Td>
<h:selectOneMenu id="combocarList"
value="#{customerBean.selectedcar}"
styleClass="comboStyle"
valueChangeListener="#{customerBean.loadothercombos}"
onchange="document.forms[0].submit()"
>
<f:selectItem
itemLabel="-----------Select--------------"
itemValue="None" />
<f:selectItems value="#{customerBean.ca开发者_运维技巧rsList}" />
</h:selectOneMenu>
</Td>
the event is called when user selects an item from dropdown list and the backbean does the processing to retrieve values of other dropdown list which works ok , BUT i also have a h:datatable which is the problem. The values won't show.
the datatable is defined as:
<h:dataTable
id="calDetails" rowClasses="oddrow,evenrow"
headerClass="thHeading" var="car"
value="#{cardetails.allinfo}">
<h:column>
<f:facet name="header">
<h:outputText id="lblCode" value="Code"></h:outputText>
</f:facet>
<h:inputHidden value="#{car.code}"></h:inputHidden>
<h:outputText id="carcodeid"
value="#{car.code}"></h:outputText>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText id="lblCode" value="Sold"></h:outputText>
</f:facet>
<h:inputHidden value="#{car.sales}"></h:inputHidden>
<h:outputText id="carsalesid"
value="#{car.sales}"></h:outputText>
</h:column>
</h:dataTable>
i have setter and getters for cardetails.allinfo
and i know when document.forms[0].submit()
is called cardetails.allinfo
is not null since as i tested it using
<h:outputText value="#{cardetails.allinfo eq null}" />
which returned false. I've been starring at it for hours and can't see my fault. would appreciate any input. Thanks
Apparently the list is just empty. A better debug is
<h:outputText value="#{not empty cardetails.allinfo}" />
This will show true
whenever the allinfo
is not null
and not empty. You could also do
<h:outputText value="#{cardetails.allinfo}" />
to see all list items in plain text as represented by ArrayList#toString()
. If you see []
then it's indeed empty. Otherwise if you see [com.example.Car@1234,com.example.Car@5678]
, then it has 2 Car
items (assuming that you didn't override its toString()
method to return a more human readable String representation as many starters do ;) ).
In case of an empty list, you'd need to debug and fix your list loading logic from the DB.
精彩评论