Dar*_*ion 2 datatable jsf nested
<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>
Run Code Online (Sandbox Code Playgroud)
我有一个实体成员他的一个属性是一个列表照片与获取/设置属性填充我不知道如何获取该值在jsf我只想要每个成员的第一张照片,因为他们有2-3张照片.它可能吗?任何其他解决方案将不胜感激.
只需使用<ui:repeat>或<h:dataTable>通常的方式迭代它.将多个迭代组件嵌套在一起是完全有效的.在这种情况下<h:dataTable>,您只需要确保将嵌套的迭代组件放在一个<h:column>.
例如
<h:dataTable value="#{bean.entities}" var="entity">
<h:column>
#{entity.property}
</h:column>
<h:column>
<ui:repeat value="#{entity.subentities}" var="subentity">
#{subentity.property}
</ui:repeat>
</h:column>
</h:dataTable>
Run Code Online (Sandbox Code Playgroud)
要么
<h:dataTable value="#{bean.entities}" var="entity">
<h:column>
#{entity.property}
</h:column>
<h:column>
<h:dataTable value="#{entity.subentities}" var="subentity">
<h:column>
#{subentity.property}
</h:column>
</h:dataTable>
</h:column>
</h:dataTable>
Run Code Online (Sandbox Code Playgroud)
当您使用旧版Mojarra 嵌套多个<ui:repeat>组件并<f:ajax>在其中使用时,您可能只会遇到问题.
<c:forEach>当嵌套在JSF迭代组件中时,只有JSTL 不起作用,原因如此解释JSF2 Facelets中的JSTL ...有意义吗?
与具体问题无关,请不要滥用<h:outputLabel>纯文本演示.它生成一个HTML <label>元素,用于按属性标记输入元素for.但是,你在代码中没有这样做.你应该使用<h:outputText>而不是.顺便说一句,我最近在初学者的代码中经常看到这一点.必须有一个坏的教程或资源滥用<h:outputLabel>这种方式,而不是<h:outputText>模板文本中的简单EL.您使用的是哪个教程/资源?然后我可以联系作者关于这种严重的错误指导.另请参见h:outputLabel及其"for"属性的用途
| 归档时间: |
|
| 查看次数: |
5775 次 |
| 最近记录: |