[FACELETS-240] UIRepeat 'value' attribute and Collection types Created: 07/Aug/07  Updated: 23/May/12  Resolved: 20/Feb/08

Status: Resolved
Project: facelets
Component/s: impl
Affects Version/s: Facelets 1.1
Fix Version/s: early access

Type: Improvement Priority: Major
Reporter: rwhitsell Assignee: facelets-issues
Resolution: Incomplete Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: All
Platform: All

Issue Links:
is duplicated by JAVASERVERFACES_SPEC_PUBLIC-1103 UIRepeat and UIData supports Iterable Resolved
Issuezilla Id: 240


I encountered a problem attempting to set the ui:repeat "value" attribute to an
instance that was a subclass of java.util.Set (specifically Hibernate's
PersistentSet class): the UIRepeat class treated it like a scalar object.

An iteration tag like ui:repeat should work with all Collection types in my
opinion. In the UIRepeat.getDataModel() method it's possible to detect an
instance of Collection and make use of the ArrayDataModel by invoking the
toArray() method on the instance. In this way a new DataModel implementation
isn't needed. I've made this change in my own copy of Facelets and it works

Hibernate happens to use Sets quite a bit, so this was important to me. I'd be
happy to submit a patch.

This issue occurs in Facelets 1.2 as well.\

Comment by mkienenb [ 13/Aug/07 ]

Note that DataModel expects an ordered Collection. This is why it doesn't
natively support any collections other than Array, List, or scrollable ResultSet.

Comment by Ryan Lubke [ 20/Feb/08 ]

Agreed with Mike. Closing.

Comment by Raj [ 05/May/12 ]

I think there is definitely a need to allow Iterables to be used with ui:repeat.
For example, sometimes there's are needs to use your custom iterable backed by an existing list. Such as when you want to iterate over a collection of entities/ or just columns read from database but get entityIds/ or read column values on iteration instead of the entity/ or column, in that case using an custom Iterable backed by a list is the nice option, but due to this limitation of ui:repeat tags this cannot be availed and unnecessarily the list needs to be rebuilt.

And limiting useful cases to arrays, list & result set does not cover all types of ordered collections.

Comment by Ed Burns [ 23/May/12 ]

I've opened this as a spec issue.

Generated at Tue Oct 13 08:32:44 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.