How To Output A List As A Comma Separated String In JSF | Example

In a JSF Page you might want to display all entries of a collection as a comma-separated list (or of course another separator). To do that you can use the JSF <ui:repeat></ui:repeat> Tag.
This JSF-Tag expects a collection assigned to the value attribute. <ui:repeat> iterates over the collection and assigns the current item to the variable, which is declared in the var attribute. The variable, assigned in the varStatus attribute has several properties. In the example we need the last property, which indicates witz a boolean value, wheater this is the last item or not.
Here is an example:

<ui:repeat value="#{myCollectionOfStrings}" var="str" varStatus="status">
	#{str}#{status.last?'':', '}
</ui:repeat>
(Visited 3,443 times, 1 visits today)

11 thoughts on “How To Output A List As A Comma Separated String In JSF | Example”

  1. Hello there, You’ve done a great job. I will certainly digg it and personally suggest to my friends. I’m sure they’ll be benefited from this site.

    Reply
  2. Howdy! Someone in my Myspace group shared this site with us so I came to check it out.
    I’m surely loving the information. I’m bookmarking and
    will be tweeting this to my followers! Outstanding blog and great style and design.

    Reply
  3. Keep up the wonderful piece of content, I read several
    posts on this site and I think that your web blog is truly appealing as well as includes plenty
    of superb information.

    Reply
  4. I’m thankful to obtain a call from a friend as he identified the important suggestions
    shared on your website. Browsing your blog post is a real superb experience.
    Thank you for considering readers like me, and I wish you the best.

    Reply
  5. I’m not sure exactly why but this website is loading very slow for me.

    Is anyone else having this issue or is it a problem on my
    end? I’ll check back later on and see if the problem still exists.

    Reply

Leave a Comment