h:数据表未填充
这是一个相关(和/或后续)问题:
因此,鉴于我有:
<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 进行处理以检索其他下拉列表的值,这可以正常工作,但我也有 ah:datatable 这是问题。值不会显示。
数据表定义为:
<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
不为空,因为我使用它测试
<h:outputText value="#{cardetails.allinfo eq null}" />
它返回 false。我已经盯着它看了好几个小时了,却看不出我的错。将不胜感激任何意见。谢谢
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.carsList}" />
</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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然该列表是空的。更好的调试是,
只要
allinfo
不null
且 不为空,就会显示true
。您还可以以纯文本形式查看所有列表项,如
ArrayList#toString()
。如果您看到[]
那么它确实是空的。否则,如果您看到[com.example.Car@1234,com.example.Car@5678]
,则它有 2 个Car
项(假设您没有覆盖它的 toString() 方法返回一个更容易理解的字符串表示形式,就像许多初学者所做的那样;))。如果列表为空,您需要调试并修复从数据库加载列表的逻辑。
Apparently the list is just empty. A better debug is
This will show
true
whenever theallinfo
is notnull
and not empty. You could also doto 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 2Car
items (assuming that you didn't override itstoString()
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.