title: Wizard Component PrimeFaces Updating other variables
body: <p>I have two tabs.
  With the wizard component, when i press the 'Next' button (FROM THE FIRST TAB), I need to populate a list(with SelectItem objects) and then show these SelectItems in a SelectOneMenu tag IN THE SECOND TAB. As i soon i have finished entering data on THE FIRST TAB and then press the 'Next' button, this SelectOneMenu tag(ON THE SECOND TAB) does not have anything in it. </p>
  
  <p><b>Basically, i need to update the next tab along with the processing of the current tab. Anyway to do this? </b></p>
  
  <p>Thanks in advance.</p>
  
  <p><img src="https://i.stack.imgur.com/JWNzs.png" alt="enter image description here"><img src="https://i.stack.imgur.com/xarci.png" alt="enter image description here"></p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;p:wizard widgetVar="wiz" showNavBar="true" flowListener="#{detentionForm.onFlowProcess}"&gt;
                  &lt;p:tab id="typeOfLeader" title="Leader Selection"&gt;
                      &lt;p:panel header="Leader Selection"&gt;
                          &lt;p:messages showSummary="true" showDetail="false"/&gt;
                          &lt;p:panelGrid columns="2"&gt;
                              #{msgs.typeOfLeaderPunishment}
                              &lt;p:selectOneMenu value="#{detentionForm.typeOfLeaderSelectedID}" style="width:400px" panelStyle="width:150px" effect="fade"&gt;
                                  &lt;f:selectItems value="#{detentionForm.teacherTypes}" var="type" itemLabel="#{type.label}" itemValue="#{type.value}" /&gt;
                              &lt;/p:selectOneMenu&gt;
                          &lt;/p:panelGrid&gt; 
                      &lt;/p:panel&gt;
                  &lt;/p:tab&gt;
                  &lt;p:tab id="typeOfPunishment" title="Punishment Type"&gt;
                      &lt;p:panel header="Type of Punishment"&gt;
                          &lt;p:panelGrid columns="2"&gt;
                              #{msgs.typeOfDetention}
                              &lt;p:selectOneMenu value="#{detentionForm.typeOfPunishment}" style="width:400px" panelStyle="width:150px" effect="fade" &gt;
                                  &lt;f:selectItems value="#{detentionForm.detentionTypes}" var="type" itemLabel="#{type.label}" itemValue="#{type.value}" /&gt;
                              &lt;/p:selectOneMenu&gt; 
                          &lt;/p:panelGrid&gt;
  
                      &lt;/p:panel&gt;
                  &lt;/p:tab&gt;
  
              &lt;/p:wizard&gt;
  </code></pre>
  
  <p><code>#{detentionForm.detentionTypes}</code> is an arraylist that needs to be populated once i press the 'Next' button to the SECOND TAB.</p>
  
  <p><br /></p>
  
  <p>Here is my backing bean:</p>
  
  <pre><code>@ViewScoped
  @Named("detentionForm")
  public class DetentionFormBean implements Serializable{
      @Resource(name="jdbc/DetentionCentre")
      private DataSource ds;
  
      private Details details = (Details) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("userDetails");
  
  
  
      private String typeOfPunishment;
      private String typeOfLeader = details.getTypeOfLeader(); //Can change if user is House Leader. Eg. They can become a teacher when making a punishment
      private int typeOfLeaderID; //ID in the database of the teacher's type of leadership
      private int typeOfLeaderSelectedID = 1; //Set default to teacher as House leader can be teacher and normal teacher will be a teacher!
      private ArrayList&lt;SelectItem&gt; detentionTypes = new ArrayList&lt;SelectItem&gt;(); //SelectItem objects that shows what punishments each teacher can do
      private ArrayList&lt;SelectItem&gt; teacherTypes = new ArrayList&lt;SelectItem&gt;(); //SelectItem objects that shows what type of leadership a teacher can be (Teacher or House Leader)
  
  
      //gets all the data necessary from the database to show on the page
      @PostConstruct
      public void initialize(){
          this.setTypeOfLeaderID(details.getUserName()); //gets the ID from the database to find out the default type of leadership
          this.findTeacherTypes(this.typeOfLeader); 
      } 
  
      public String onFlowProcess(FlowEvent event) {  //change later for backing as well &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
              String stepToGo = event.getNewStep();
              if(stepToGo.equals("typeOfPunishment")){
                  this.findDetentionTypes();
  
              }
          return stepToGo;
  
      }
  
      //populates teacherType Arraylist depending the user's teacher type. House Leader can be a Teacher or a House Leader.
      private void findTeacherTypes(String type) {
          if(type.equals("House Leadership Team")){
              this.teacherTypes.add(new SelectItem(Integer.toString(this.typeOfLeaderID), type)); //House leader is 2
              this.teacherTypes.add(new SelectItem(Integer.toString(this.typeOfLeaderID - 1), "Teacher" )); //Teacher is 1
          }else{ //type is Teacher
              this.teacherTypes.add(new SelectItem(Integer.toString(this.typeOfLeaderID), type)); //Teacher is 1
          }
      }
  
  
      //populates detentiontypes depending on type of leader
      private void findDetentionTypes() {
          System.out.println("&gt;&gt;&gt;&gt;Inside findDetentionTypes()!!!");
          PreparedStatement ps;
          Connection con;
          String sqlInitialData = "SELECT r.punishment_type, p.type FROM detentioncentredb.tbl_teacher_roles_allowed_punishments r, detentioncentredb.tbl_punishment_types p WHERE r.teacher_roles = ? AND p.ID = r.punishment_type";
          ResultSet rs;
  
          try {
              con = ds.getConnection();
              ps = con.prepareStatement(sqlInitialData);
              ps.setString(1, Integer.toString(this.typeOfLeaderSelectedID)); 
              rs = ps.executeQuery();
              while(rs.next()){
                  SelectItem s = new SelectItem(rs.getString("punishment_type"), rs.getString("type"));
                  this.detentionTypes.add(s);
              }
              rs.close();
              ps.close();
              con.close();
  
          } catch (SQLException ex) {
              Logger.getLogger(DetentionFormBean.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  
      //getter and setter methods
  
      public String getTypeOfPunishment() {
          return typeOfPunishment;
      }
  
      public void setTypeOfPunishment(String typeOfPunishment) {
          this.typeOfPunishment = typeOfPunishment;
      }
  
      public String getTypeOfLeader() {
          return typeOfLeader;
      }
  
      public ArrayList&lt;SelectItem&gt; getDetentionTypes() {
          return detentionTypes;
      }
  
      public ArrayList&lt;SelectItem&gt; getTeacherTypes() {
          return teacherTypes;
      }
  
      public int getTypeOfLeaderID() {
          return typeOfLeaderID;
      }
  
      //gets the typeOfLeader the current user is from the database. This retrieves the ID of the teacher's type of leadership. NOT WHAT THE TEACHER SELECTED.
      private void setTypeOfLeaderID(int userName){
          PreparedStatement ps;
          Connection con;
          String sqlTypeOfLeaderID = "SELECT TypeOfLeader FROM detentioncentredb.tbl_teachers WHERE RegNumber = ?";
          ResultSet rs;
          try {
              con = ds.getConnection();
              ps = con.prepareStatement(sqlTypeOfLeaderID);
              ps.setInt(1, userName);
              rs = ps.executeQuery();
              while(rs.next()){
                  this.typeOfLeaderID = rs.getInt("TypeOfLeader");
              }
              rs.close();
              ps.close();
              con.close();
          } catch (SQLException ex) {
              Logger.getLogger(DetentionFormBean.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  
      public int getTypeOfLeaderSelectedID() {
          return typeOfLeaderSelectedID;
      }
  
      public void setTypeOfLeaderSelectedID(int typeOfLeaderSelectedID) {
          this.typeOfLeaderSelectedID = typeOfLeaderSelectedID;
      }
  
  
  }
  </code></pre>