Search code examples
primefacesforeachuirepeat

ui:repeat and c:foreach dont return the same organisation


I have a loop that contains a list of properties I would like to display this list on 2 columns, but I can not.   they are displayed by unordered, against if I use c: For Each place of ui: repeat the problem is resolved

<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>   

Haw can I fixe the problem .helpe please :)


Solution

  • You could switch to using <h:dataTable> to iterate over the components:

    <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>
    

    Enclose it within a <p:panel> to make it work. Otherwise, make use of <c:forEach> as it's a good fit for your use case.