【发布时间】:2013-05-11 13:19:45
【问题描述】:
<h:dataTable value="#{SearchingBeans.list}" var="entry">
<h:column>
<f:facet name="header">
<h:outputLabel>Photo</h:outputLabel>
</f:facet>
</h:column>
<h:column>
<f:facet name="header">
<h:outputLabel>Pseudo</h:outputLabel>
</f:facet>
<h:outputLabel value="#{entry.pseudo}"></h:outputLabel>
</h:column>
<h:column>
<f:facet name="header">
<h:outputLabel>Description</h:outputLabel>
</f:facet>
<h:outputLabel value="#{entry.description}"></h:outputLabel>
</h:column>
<h:column>
<f:facet name="header">
<h:outputLabel>Photo</h:outputLabel>
</f:facet>
<h:outputLabel value="#{entry.photo[0].path}"></h:outputLabel> <-- this a List
</h:column>
</h:dataTable>
我有一个实体成员,他的属性之一是带有 get/set 的列表照片 该属性已填充 我不知道如何在 jsf 中获取该值我只想要每个成员的第一张图片,因为他们有 2-3 张照片。这可能吗??任何其他解决方案将不胜感激。
【问题讨论】:
-
如果你有
entry.list类型为List,你可以用ELempty检查它的内容,然后用[0]访问它的第一个元素,如果我正确理解你的想法的话。