ui:repeat和c:foreach不会返回同一个组织

时间:2013-04-29 12:57:44

标签: primefaces foreach uirepeat

我有一个包含属性列表的循环 我想在2列上显示这个列表,但我不能。 它们是无序显示的,如果我使用c则反对:对于ui的每个地方:重复 问题解决了

<p:panel id="panlecart2" header ="Caracteristique selon la categorie" toggleable="true" rendered="true" style="width=900px;">            
            <h:panelGrid  id="panlecart" columns="2" cellpadding="5" rendered="true" style="width=900px;">                         
            <ui:repeat var="var1" value="#{composantbean.categorie.proprietes.toArray()}">            
            <h:outputText value="#{var1.nomProp }(#{var1.unite}  )"  />
            <h:inputText value="" />  

            </ui:repeat>             
         </h:panelGrid>
          </p:panel>   

唧唧我可以解决这个问题。请问:)

2 个答案:

答案 0 :(得分:1)

ui:repeat的呈现时间晚于c:forEach。这是一个explanation

c:forEach是这里的方法,因为这是在视图构建时调用的。

在视图呈现期间调用

ui:repeat,因此p:panel将不知道ui:repeat创建的数据。

答案 1 :(得分:1)

您可以切换到使用<h:dataTable>来迭代组件:

<h:dataTable var="var1" value="#{composantbean.categorie.proprietes.toArray()}">
    <h:column>
        <h:outputText value="#{var1.nomProp }(#{var1.unite}  )"  />
    </h:column>
    <h:column>
        <h:inputText value="" />  
    </h:column>
</h:dataTable>

将其封入<p:panel>以使其有效。否则,请使用<c:forEach>,因为它非常适合您的用例。

相关问题