Note that there are some explanatory texts on larger screens.

plurals
  1. POPersist many to many with SelectBooleanCheckbox
    primarykey
    data
    text
    <p>My question is similar to <a href="https://stackoverflow.com/questions/10266390/jpa-persist-many-to-many">JPA persist many to many</a></p> <p>But, I have two entities: Roles and Users, with a Many to Many relation, that is represented by rolesusers table. In my application, I'm using JSF 2.0, and I have a form to manipulate User data, and a form with a list of all Roles names and a selectBooleanCheckbox to see the user's roles (checked if yes). Additionally it must have the possibility to add or remove a rol (checking or unchecking the selectBooleanCheckbox), but when I do it, I have two problems:</p> <p>1: To check the role that this user has, I have in the value of the selectBooleanCheckbox this syntax:</p> <p></p> <pre><code>&lt;h:column&gt; &lt;f:facet name="header"&gt; &lt;h:outputText value="ASIGNADO"/&gt; &lt;/f:facet&gt; &lt;h:panelGroup rendered="#{usuariosController.selected.rolesList.contains(itemRole)}"&gt; &lt;h:selectBooleanCheckbox value="#{true}"&gt; &lt;f:ajax listener="#{rolesView.selectRoleListener(usuariosController.selected, itemRole)}" render="@form" /&gt; &lt;/h:selectBooleanCheckbox&gt; &lt;/h:panelGroup&gt; &lt;h:panelGroup rendered="#{!usuariosController.selected.rolesList.contains(itemRole)}"&gt; &lt;h:selectBooleanCheckbox value="#{false}"&gt; &lt;f:ajax listener="#{rolesView.selectRoleListener(usuariosController.selected, itemRole)}" render="@form" /&gt; &lt;/h:selectBooleanCheckbox&gt; &lt;/h:panelGroup&gt; &lt;/h:column&gt; </code></pre> <p>But when the <code>selectRoleListener</code> is executed, it throws a <code>javax.faces.component.UpdateModelException /users.xhtml @224,102 value="#{true}": Illegal Syntax for Set Operation</code>.</p> <p>2: If I remove the <code>value="#{true}"</code> and replace it with <code>value="true"</code>, the checkbox is not selected when the user has the role specified in list, but it seems the selectRoleListener is executed, but the changes are not visible in data base.</p> <p>Can you help me with this case? I hope you understood me.</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload