You can check the current round loop with the varStatus
attribute and print an intermediate </div><div style="float: left;">
if necessary.
eg. every 3 elements:
<div style="float: left;"> <ui:repeat value="#{bean.list}" var="item" varStatus="loop"> <h:outputText value="</div><div style='float: left;'>" escape="false" rendered="#{not loop.first and loop.index % 3 == 0}" /> <div>#{item}</div> </ui:repeat> </div>
Please note that this cannot be done as plain HTML inside <h:panelGroup>
, because it will lead to uncorrected XML, therefore <h:outputText escape="false">
with them as XML entities.
Update according to the comments, here's an alternative approach having a <div>
defined only once, which is probably less confusing:
<ui:repeat value="#{bean.list}" var="item" varStatus="loop"> <h:outputText value="<div style='float: left;'>" escape="false" rendered="#{loop.index % 3 == 0}" /> <div>#{item}</div> <h:outputText value="</div>" escape="false" rendered="#{loop.last or (loop.index + 1) % 3 == 0}" /> </ui:repeat>
source share