kgautron
kgautron

Reputation: 8263

Proper way to display separators in between labels and not after

I have a collection I want to display using the <ui:repeat> JSF tag.

What would be a proper way to add separators between the elements of the collection?

Because obviously if I do :

<ui:repeat value="#{myBean.myCollection}" var="toPrint">
   #{toPrint.property}, 
</ui:repeat>

the last one will have a comma after it though it is the last.

Upvotes: 1

Views: 951

Answers (1)

mrembisz
mrembisz

Reputation: 12880

You can try:

<ui:repeat value="#{myBean.myCollection}" var="toPrint" varStatus="status">
   #{toPrint.property}#{status.last ? '' : ','}
</ui:repeat>

More info about varStatus.

Upvotes: 8

Related Questions