[jboss-user] [JBoss Seam] - h:SelectManyListbox, s:SelectItems and Many-to-Many mapping
ovistanciu
do-not-reply at jboss.com
Mon Feb 4 10:30:49 EST 2008
Hello.
Not sure if I'm addressing a known bug, but here it goes.
I'm using Seam 2.0.0.GA, JBoss AS 4.2.2, JDK 1.5
I have a Many-to-Many mapping:
Location entity:
| private Collection<UserGroup> userGroups;
|
| @ManyToMany(TargetEntity=ro.ebsoft.doorcontrol.applogic.entity.UserGroup.class,
| cascade={CascadeType.MERGE, CascadeType.PERSIST})
| @JoinTable(name="UserGroup_Location",
| joinColumns={@JoinColumn(name="locationId")}, inverseJoinColumns={@JoinColumn(name="userGroupId")})
| public Collection<UserGroup> getUserGroups() {
| return userGroups;
| }
|
| public void setUserGroups(Collection<UserGroup> userGroups) {
| this.userGroups = userGroups;
| }
|
and UserGroup entity
| private Collection<Location> locations = null;
|
| @ManyToMany(
| cascade={CascadeType.PERSIST, CascadeType.MERGE},
| mappedBy="userGroups",
| targetEntity=Location.class
| )
| public Collection<Location> getLocations() {
| return locations;
| }
|
| public void setLocations(Collection<Location> locations) {
| this.locations = locations;
| }
|
|
When adding a new UserGroup, a user can select any number of locations for the group.
userGroup.xhtml :
| <h:selectManyListbox id="locationsListBox" value="#{userGroupHome.instance.locations}"
| disabled="#{not s:hasRole('admin')}">
| <s:convertEntity/>
| <s:selectItems value="#{locationList.resultList}" var="location" label="#{location.locationName}"/>
| </h:selectManyListbox>
|
When I try to save a new group (for instance, with the 2 top locations from the listbox), there's a failed validation. Faces Message: Conversion Error setting value '0 1' for '#{userGroupHome.instance.locations}'.
I understand there's a problem binding a Set to a h:selectManyListBox (should use ArrayList). When trying to change Collection<Location> locations; to ArrayList<Location> locations; Hibernate notifies that it does not support it (mapping many to many to something else than a Collection).
What to do? Does anyone have a fix for this problem?
Thank you for your time.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4126217#4126217
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4126217
More information about the jboss-user
mailing list