[JAVASERVERFACES_SPEC_PUBLIC-1103] UIRepeat and UIData supports Iterable Created: 23/May/12  Updated: 08/Mar/15  Resolved: 02/Mar/15

Status: Resolved
Project: javaserverfaces-spec-public
Component/s: Components/Renderers
Affects Version/s: None
Fix Version/s: 2.3

Type: New Feature Priority: Major
Reporter: Ed Burns Assignee: Manfred Riem
Resolution: Fixed Votes: 13
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File changebundle.txt    
Issue Links:
Duplicate
duplicates FACELETS-240 UIRepeat 'value' attribute and Collec... Resolved
Related
is related to JAVASERVERFACES-3785 Implement JAVASERVERFACES_SPEC_PUBLIC... Closed
is related to JAVASERVERFACES_SPEC_PUBLIC-1078 Have DataModel implementations regist... Reopened
is related to JAVASERVERFACES_SPEC_PUBLIC-1364 UIRepeat and UIData supports Map Resolved

 Description   

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
beautifully.

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.\



 Comments   
Comment by Aditya [ 10/Sep/12 ]

Not only just collections, ui:repeat should also support iterables as well for the value attribute.

Comment by Ertio lew [ 11/Mar/13 ]

ui:repeat should allow iterables to be used with them. Currently we are required to create a new list from iterable just to support ui:repeat. This limitation should be removed.

Comment by kithouna [ 27/Sep/13 ]

The collection / iterable to datamodel conversion should be abstracted and put in a global place. Now DataTable and UIRepeat do pretty much the same thing and differences crop up between them that benefit no one.

Then, we the users should be able to register additional datamodel converters, so we can register something like OmniFaces' IterableDataModel and they would be automatically used by DataTable, UIRepeat and others.

Comment by Ed Burns [ 01/Aug/14 ]

Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

Comment by Manfred Riem [ 01/Aug/14 ]

Setting priority to Major

Comment by arjan tijms [ 17/Feb/15 ]

Not only just collections, ui:repeat should also support iterables as well for the value attribute.

I agree, and have adjusted the title of the issue to reflect that. If UIRepeat supports iterables, UIData should support that as well. Thanks for this suggestion!

Comment by Ed Burns [ 23/Feb/15 ]

Section 4.1.3.2 in the spec PDF must be updated as well for this issue to be considered closed. The relevant text in the latest version of the spec is the following:

The current value identified by the value property is normally of type DataModel. [P1-start-uidataModel]However, a
DataModel wrapper instance must automatically be provided by the JSF implementation if the current value is of one
of the following types:
java.util.List
Array of java.util.Object
java.sql.ResultSet (which therefore also supports javax.sql.RowSet)
javax.servlet.jsp.jstl.sql.Result
Any other Java object is wrapped by a DataModel instance with a single row.[P1-end]
Convenience implementations of DataModel are provided in the javax.faces.model package for each of the
above (see Section 4.2.1.4 “Concrete Implementations”), and must be used by the UIData component to create the
required DataModel wrapper.

Comment by Ed Burns [ 23/Feb/15 ]

I have some comments about the changebundle, but I'll add them on the impl issue JAVASERVERFACES-3785.

Comment by arjan tijms [ 23/Feb/15 ]

The relevant text in the latest version of the spec is the following:

The spec currently lists:

  • java.util.List
  • Array of java.util.Object
  • java.sql.ResultSet
  • javax.servlet.jsp.jstl.sql.Result
  • (Object wrapped as single row)

But java.util.Collection is missing, while this was added via a spec issue (JAVASERVERFACES_SPEC_PUBLIC-479).

The new list would therefor become:

  • java.util.List
  • Array of java.util.Object
  • java.sql.ResultSet
  • javax.servlet.jsp.jstl.sql.Result
  • java.util.Collection
  • java.lang.Iterable
  • (Object wrapped as single row)

Also, a similar list appears in UIRepeat, but I can't find anything about that in the spec.

The updated text in section 4.1.3.2 after this update (and after taking into account the change from 2.2) would be the following:

The current value identified by the value property is normally of type DataModel. [P1-start-uidataModel]However, a DataModel wrapper instance must automatically be provided by the JSF implementation if the current value is of one of the following types:

java.util.List
Array of java.util.Object
java.sql.ResultSet (which therefore also supports javax.sql.RowSet)
javax.servlet.jsp.jstl.sql.Result
java.util.Collection
java.lang.Iterable
Any other Java object is wrapped by a DataModel instance with a single row.[P1-end]

Comment by arjan tijms [ 25/Feb/15 ]

Patch for ui:repeat's taglib/tld doc

Comment by arjan tijms [ 02/Mar/15 ]

Oops, UIRepeat changes did not make it into previous bundle

Comment by Manfred Riem [ 02/Mar/15 ]

Applied to 2.3 trunk,

svn commit -m "Fixes https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1103, UIRepeat and UIData supports Iterable"
Sending jsf-ri/conf/share
Sending jsf-ri/conf/share/ui.taglib.xml
Sending jsf-ri/conf/share/ui.tld
Transmitting file data ..
Committed revision 14464.

Generated at Mon Apr 24 09:18:36 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.