I am doing a project using Struts2 and I have a problem assigning a set collection.
Here\'s my Action (I eliminated the irrelevant part)
public class
Set is a Collection and as any other collection could be indexed by a property.
@Element(value = Student.class)
@Key(value = Integer.class)
@KeyProperty(value = "id")
@CreateIfNull(value = true)
private Set students = new HashSet(0);
//getter and setter, also for Student class that should have Integer id.
in JSP
More about this see
Indexing a collection by a property of that collection.
It is also possible to obtain a unique element of a collection by passing the value of a given property of that element. By default, the property of the element of the collection is determined in
using->conversion.properties KeyProperty_xxx=yyy, wherexxxis the property of the beanClassthat returns the collection andyyyis the property of the collection element that we want to index on.