title: How to use SelectManyCheckbox with two ArrayList? - Primefaces
body: <p>I'm trying to implement a <a href="http://www.primefaces.org/showcase/ui/selectManyCheckbox.jsf" rel="nofollow"><code>&lt;p:selectManyCheckbox&gt;</code></a> but I'm having no success. </p>
  
  <p><strong>Now I have the following architecture:</strong></p>
  
  <pre><code>Course - have many Disciplines
  Discipline - belongs to none, one or many Courses.
  </code></pre>
  
  <p>In <code>Course</code> class I have two <code>ArrayList&lt;Discipline&gt;</code>:</p>
  
  <pre><code>public class CourseMBean{
  
      (...)
      // Stores all disciplines
      private static ArrayList&lt;Discipline&gt; allDisciplines;
  
      // Stores only the disciplines that's already associated with this course.
      private static ArrayList&lt;Discipline&gt; courseDisciplines;
  
      (get and set for the arraylists)
      (...)
  }
  </code></pre>
  
  <p>All data comes from a MYSQL DB, but that isn't the question. Now I want create a new Course, so I don't have anything in courseDisciplines. </p>
  
  <p>I want show allDisciplines in checkboxes, and want that when user select one checkbox, the object Discipline of this checkbox be added in courseDisciplines - and when unselect one checkbox, remove the discipline from the courseDsiciplines. </p>
  
  <p><strong>My JSF 2.0 code is following:</strong></p>
  
  <pre><code>&lt;p:selectManyCheckbox id="disciplines" value="#{courseMBean.allDisciplines}" layout="grid" columns="2"&gt;                                          
       &lt;f:selectItems value="#{courseMBean.courseDisciplines}" /&gt;
  &lt;/p:selectManyCheckbox&gt;
  </code></pre>
  
  <p>This actually shows all disciplines without any selected checkboxes, what's right. But when I select some checkboxes and submit the form I try to print the elements inside courseDisciplines, and this don't show anything in console. </p>
  
  <p><strong>What I'm doing wrong?</strong>  </p>