Any reason why a such asSet<MyObject> objects = new HashSet<MyObject>(); shouldn’t work in the JSF Datatable? It works with List.
Any reason why a such as Set<MyObject> objects = new HashSet<MyObject>(); shouldn’t work in
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As to why a
Setin general isn’t supported, this is because this data structure is never intented to hold a collection of objects which is ordered by an index. TheListdoes that and this data structure is the most sensible data structure to represent the value of anUIDatacomponent. TheDataModelinterface, which represents the wrapped value of theUIDatacomponents and holds the row indexes and remembers the current row for iteration on render and form submit processing on postback, supports from the Java collection classes only theListinterface in flavor ofListDataModel.After a long decision process (especially pushed by Hibernate/JPA community who generally uses
Setfor n-m relationships), the JSF spec team has for the upcoming JSF 2.2 finally decided to let theDataModelinterface support theCollectioninterface instead of alone theList, with help of the newCollectionDataModelimplementation. This supports sets as well. See also JSF spec issue 479. You should only keep in mind to useLinkedHashSetinstead ofHashSet, certainly if your intention is to have an editable data table. ALinkedHashSetmaintains the ordering of the elements.