Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF -- <ui:repeat /> over a java.util.Set?

Tags:

jsf

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?

like image 244
Shadowman Avatar asked Oct 25 '10 18:10

Shadowman


2 Answers

The easiest way to finish the deal at page without modifying the class is converting the set to an array like this.

<ui:repeat value="#{myBean.mySet.toArray()}" var="_myvar">
like image 120
prageeth Avatar answered Nov 03 '22 08:11

prageeth


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> getListFromSet(Set<T> set) {
  return new ArrayList<T>(set);
}

You should avoid using c:forEach; here is an article on why.

like image 39
Shervin Asgari Avatar answered Nov 03 '22 09:11

Shervin Asgari