views:

37

answers:

2

Does the <ui:repeat /> tag support iterating over a java.util.Set? I've tried iterating over my JPA domain entity objects contained in a Set, but receive errors. Is there something I'm missing? Does an additional flag need to be present or something?

+2  A: 

Consider using c:forEach instead. It appears that ui:repeat does not support sets (i.e. requires some sort of ordering property).

Otherwise you can create your own tag as described in: http://techblog.bozho.net/?p=28

AdamH
+1 for the site link.
Harry Pham
Do **NOT** consider using `c:forEach`: http://www.ilikespam.com/blog/c:foreach-vs-ui:repeat-in-facelets
Shervin
It completely depends on what the set is that you are iterating over and if it compile time or not. So if that is the case then you CAN use `c:forEach`.
AdamH
Yes if you know what you are doing, then you can use `c:forEach`, but I read your post as that `you should consider using c:forEach`, and this is not the case. Better using `ui:repeat` to avoid problems
Shervin
+5  A: 

No the ui:repeat does not support Set. Nor does h:dataTable.

You should return a List from the Set, and use that instead.

public List<T> getListAsSet(Set<T> set) {
  return new ArrayList<T>(set);
}

You should avoid using c:forEach. Why can be read here

Shervin