h:未填充数据表 [英] h:datatable not populated
问题描述
这是一个与(和/或跟进)相关的问题:
This is a related (and or follow up) issue to :
因此,鉴于我有:
<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.carsList}" />
</h:selectOneMenu>
</Td>
当用户从下拉列表中选择一个项目,并且backbean进行处理以检索工作正常的其他下拉列表的值时,将调用该事件,但是我也有一个h:datatable,这就是问题所在.这些值将不会显示.
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.
数据表定义为:
<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>
我有cardetails.allinfo
的setter和getter,并且我知道何时调用document.forms[0].submit()
的cardetails.allinfo
不为null,因为当我使用
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}" />
返回false.我已经盯着看了好几个小时,看不到我的错.将不胜感激任何投入.谢谢
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}" />
只要allinfo
不为null
并且不为空,它将显示true
.你也可以做
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.
这篇关于h:未填充数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!