-
30. Re: how to use s:selectItems with h:selectManyCheckbox
pmuir Mar 19, 2008 4:54 PM (in response to anatorian)Read Martin's post just above yours. From Seam 2.0.1 the EntityConverter will work with a Hibernate session too.
-
31. Re: how to use s:selectItems with h:selectManyCheckbox
irace Mar 19, 2008 6:06 PM (in response to anatorian)Thanks for your answer Pete.
I've upgraded to Seam 2.0.1, and now I can use s:convertEntity within h:selectManyCheckbox and set the EntityConverter linked to Hibernate session in components.xml
But... I've still got the same message. In fact, not exactly the same. At first, the value shown in the message was the result of the role.toString() method. Now, it is the entity Id. So, the EntityConverter must be at least partially ok...
<h:selectManyCheckbox id="roles" value="{user.roles}"> <s:selectItems value="{roleList}" var="role" label="#{role.rolename}" /> <s:convertEntity /> </h:selectManyCheckbox>
In this, {user.roles} is a Set, and {roleList} is a List. I've got no problem reading from the Set, but it seems the problem comes when writing to it. Am I right ? Following Martin's post can lead me somewhere there ? (I doesn't seem to me, as Martin's example concerns data backing up table or selectItems, imho)
Thanks,
Thom'
-
32. Re: how to use s:selectItems with h:selectManyCheckbox
mars1412 Mar 19, 2008 6:19 PM (in response to anatorian)did you forget the # in your selectItems value attribute?
value="{roleList}
-
33. Re: how to use s:selectItems with h:selectManyCheckbox
irace Mar 19, 2008 6:19 PM (in response to anatorian)
(I doesn't seem to me, as Martin's example concerns data backing up table or selectItems, imho)
With that, I want to say that it seems to me that Martin's example is usable for {roleList}, but not for {user.roles} (or maybe I don't see how) and my pb comes when setting values to {user.roles} Set
Thom'
-
34. Re: how to use s:selectItems with h:selectManyCheckbox
irace Mar 19, 2008 6:20 PM (in response to anatorian)
Martin Trummer wrote on Mar 19, 2008 06:19 PM:
did you forget the # in your selectItems value attribute?
value="{roleList}
In my post, I did
In my code, I didn't :)T.
-
35. Re: how to use s:selectItems with h:selectManyCheckbox
fernando_jmt Mar 19, 2008 11:17 PM (in response to anatorian)I also have User-Role ManyToMany relation which uses List instead Set and it's working pretty good.
Can you try with List instead Set ?
-
36. Re: how to use s:selectItems with h:selectManyCheckbox
irace Mar 20, 2008 1:06 PM (in response to anatorian)I've switched to a List and hibernate bag, and all seems to work fine. Thanks for your help !
Still, are there any plans to support the Set semantics in this kind of components ? The Set is pretty useful in DB relationships handling...
Thanks again
Thom' -
37. Re: how to use s:selectItems with h:selectManyCheckbox
pmuir Mar 25, 2008 11:14 AM (in response to anatorian)In JSF 2, yes. Or do this.
-
38. Re: how to use s:selectItems with h:selectManyCheckbox
tikus Jul 9, 2008 6:00 PM (in response to anatorian)I've also tried Lists and they work BUT when updating collection all elements gets removed and inserted again. Im not happy about that. Performance suffer and design as well.
So I've worked around this problem by creating temporary List from Set in Seam Component at first for use by selectmany??? jsf component
private List<Role> prirazeneRole; public List<Role> getPrirazeneRole() { if (prirazeneRole==null) prirazeneRole = new ArrayList<Role>(getInstance().getSeznamroli()); //getSeznamroli returns Set<Role> in Entity bean return prirazeneRole; }
when saving
@Override public String persist() { if (prirazeneRole!=null) getInstance().setSeznamroli(new HashSet<Role>(prirazeneRole)); return super.persist(); } @Override public String update() { if (prirazeneRole!=null){ getInstance().getSeznamroli().retainAll(prirazeneRole); getInstance().getSeznamroli().addAll(prirazeneRole); } return super.update(); }
I tried indexed Lists with indexed column (idbag)? as recommended on hibernate forum and that worked only when inserting or updating single items. If this collection was bound directly to selectmany??? then after update was all items removed from collection even if they shouldnt and than reinserted again. I didnt find any other source of explanation why this happen. I would be glad if somebody explained the right way of handling @ManyToMany mappings with these jsf components and seam framework together while keeping updates efficient (not removing whole collection with every update)