ui:repeat和h:panelGrid [英] ui:repeat and h:panelGrid
问题描述
使用类似的东西
时<h:panelGrid columns="1">
<ui:repeat var="o" value="#{mybean.list}">
<h:outputText value="#{o.text}"/>
</ui:repeat>
</h:panelGrid>
用10个列表项,我只能得到1行,例如:1 tr的tr,而当我使用c:forEach时我得到10(但是c:forEach实际上是邪恶的,它用ajax弄乱了一切)>
我使用mojarra 1.2-这是MyFaces实现中不存在的典型Mojarra错误吗?它会在Mojarra的2.x版本中消失吗?
输出完全符合预期并已指定. <ui:repeat>
是渲染时间标签,而不是像<c:forEach>
这样的视图构建时间标签.构建视图后,<h:panelGrid>
最终带有1个子组件(<ui:repeat>
本身),而不是像<c:forEach>
那样具有 n <h:outputText>
组件.
您需要一个<h:dataTable>
.正是为此目的而设计的.
<h:dataTable var="o" value="#{mybean.list}">
<h:column>
<h:outputText value="#{o.text}"/>
</h:column>
</h:dataTable>
另请参见:
When using something like
<h:panelGrid columns="1">
<ui:repeat var="o" value="#{mybean.list}">
<h:outputText value="#{o.text}"/>
</ui:repeat>
</h:panelGrid>
with lets say 10 list entries I only get 1 row e.g.: one tr with 1 td whereas when I use c:forEach i get 10 (but c:forEach is in fact evil, it messes up everything with ajax)
I use mojarra 1.2 - is this a typical Mojarra bug which does not exist in the MyFaces implementation? Will it disappear in 2.x of the Mojarra releases?
The output is fully as expected and specified. The <ui:repeat>
is a render time tag, not a view build time tag like <c:forEach>
. After building the view, <h:panelGrid>
ends up with 1 child component (the <ui:repeat>
itself), not with n <h:outputText>
components like as with <c:forEach>
.
You need a <h:dataTable>
instead. It's designed for exactly this purpose.
<h:dataTable var="o" value="#{mybean.list}">
<h:column>
<h:outputText value="#{o.text}"/>
</h:column>
</h:dataTable>
See also:
这篇关于ui:repeat和h:panelGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!