title: passing the selected object from list of objects that each one has its own button
body: <p>I’m working on a web-app that displays list of objects, each object has its own modal when clicked inside the modal there are two dropdown menus and a button that is supposed to call a method add in a bean, to perform an action and add the selected object while taking three values, selected object, selected two items from the two drop downs and spinner’s value. </p>
  
  <pre><code>&lt;ui:repeat value="#{ViewTeacher.teacherList}" var="teacher"
  varStatus="status"&gt;
  
  
  &lt;h:panelGroup layout="block" styleClass="name"&gt;
  &lt;p&gt;#{teacher.name}&lt;/p&gt;
  
  &lt;/h:panelGroup&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  &lt;a onclick="viewModal(#{status.index})" class="btn btn-success"&gt;view&lt;/a&gt;
  
  &lt;h:panelGroup id="modal" layout="block" class="modal"
  style="max-width: 44em;" tabindex="1"&gt;
  &lt;h:panelGroup class="modal-content" layout="block"&gt;
  &lt;span class="close" onclick="modClose()"&gt;&amp;times;&lt;/span&gt;
  
  &lt;h:outputText styleClass="description" value="#{teacher.name}" /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  
  &lt;br /&gt;
  students
  
  
  &lt;h:selectOneMenu value="ok" class="form-control"&gt;
  
  &lt;f:selectItems value="#{teacher.students}" var="s"
  itemValue="#{s.id}" itemLabel="#{s.name}" /&gt;
  
  
  
  &lt;/h:selectOneMenu&gt;
  
  
  classes
  
  &lt;h:selectOneMenu value="ok" class="form-control"&gt;
  &lt;f:selectItems value="#{teacher.classes}" var="c"
  itemValue="#{c.id}" itemLabel="#{c.name}" /&gt;
  &lt;/h:selectOneMenu&gt;
  &lt;br /&gt;
  
  &lt;h:panelGroup layout="block" styleClass="form-group"&gt;
  
  
  &lt;p:spinner min="1" max="10" /&gt;
  
  &lt;/h:panelGroup&gt;
  
  &lt;h:commandButton id="submitButton" styleClass="btn btn-success" value="ADD"&gt;
  &lt;!—-this is the button that is supposed to take the values
  
  
  
  &lt;/h:commandButton&gt;
  
  &lt;a onclick="modClose()" class="btn btn-success"&gt;CANCEL&lt;/a&gt;
  
  &lt;/h:panelGroup&gt;
  
  
  &lt;/h:panelGroup&gt;
  
  
  &lt;/ui:repeat&gt;
  </code></pre>
  
  <p>I tried :</p>
  
  <pre><code>&lt;f:param name="name1" value="China" /&gt;
  </code></pre>
  
  <p>But the fact that param’s name will get repeated, will make it the same all the time and might be set to the latest object retrieved, </p>
  
  <p>Any recommendation?</p>
  
  <p>UPDATE: </p>
  
  <pre><code>&lt;p:commandLink styleClass="btn btn-success" process="@this"
      onclick="viewModal(#{status.index});"&gt;
      &lt;h:outputText value="ADD" /&gt;
                                  &lt;f:setPropertyActionListener
          value="#{teacher.id}" target="#{ViewTeacher.selectedTeacher}" /&gt; 
  
          &lt;/p:commandLink&gt;
  </code></pre>
  
  <p>Made this change to pass the teacher's id but it's still null in the bean </p>