开发者

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

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


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">


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜