title: How to redirect primefaces wizard to first tab after submit on last tab
body: <p>I am using primefaces 3.2. I have prepared wizard which insert user information on same page in datatable. Wizard get information tab by tab and submitted on confirmation tab. Also it will reflected on same page on datatable. It is working fine. Now I need to update multiple users. For that I have to navigate wizard from submit button to first tab.
  Any help will be appreciated.
  My code is as below</p>
  
  <p>wizard.xhtml</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core"&gt;
  &lt;h:head&gt;
      &lt;title&gt;Wizard Example&lt;/title&gt;
      &lt;script type="text/javascript" &gt;
          function resetWizard() {
              wiz.loadStep(wiz.cfg.steps[0], true);
          }
      &lt;/script&gt;
  &lt;/h:head&gt;
  &lt;h:body&gt;
      &lt;h:form id="form"&gt;
  
          &lt;!-- &lt;p:growl id="growl" sticky="true" showDetail="true"/&gt; --&gt;
          &lt;p:growl redisplay="false" life="3000" id="mymessage" autoUpdate="true"/&gt;
          &lt;p:wizard widgetVar="wiz"
                    flowListener="#{userWizard.onFlowProcess}" showNavBar="true" &gt;
  
              &lt;p:tab id="personal" title="Personal" &gt;
  
                  &lt;p:panel header="Personal Details"&gt;
  
                      &lt;h:messages errorClass="error"/&gt;
  
                      &lt;h:panelGrid columns="2" columnClasses="label, value" styleClass="grid"&gt;
                          &lt;h:outputText value="Firstname: *" /&gt;
                          &lt;p:inputText required="true" label="Firstname"
                                       value="#{userWizard.user.firstname}" /&gt;
  
                          &lt;h:outputText value="Lastname: *" /&gt;
                          &lt;p:inputText required="true" label="Lastname"
                                       value="#{userWizard.user.lastname}" /&gt;
  
                          &lt;h:outputText value="Age: " /&gt;
                          &lt;p:inputText value="#{userWizard.user.age}" /&gt;
  
  
                      &lt;/h:panelGrid&gt;
                  &lt;/p:panel&gt;
              &lt;/p:tab&gt;
  
              &lt;p:tab id="address" title="Address" &gt;
                  &lt;p:panel header="Adress Details"&gt;
  
                      &lt;h:messages errorClass="error"/&gt;
  
                      &lt;h:panelGrid columns="2" columnClasses="label, value"&gt;
                          &lt;h:outputText value="Street: " /&gt;
                          &lt;p:inputText value="#{userWizard.user.street}" /&gt;
  
                          &lt;h:outputText value="Postal Code: " /&gt;
                          &lt;p:inputText value="#{userWizard.user.postalCode}" /&gt;
  
                          &lt;h:outputText value="City: " /&gt;
                          &lt;p:inputText value="#{userWizard.user.city}" /&gt;
  
  
                      &lt;/h:panelGrid&gt;
                  &lt;/p:panel&gt;
              &lt;/p:tab&gt;
  
              &lt;p:tab id="contact" title="Contact" &gt;
                  &lt;p:panel header="Contact Information"&gt;
  
                      &lt;h:messages errorClass="error"/&gt;
  
                      &lt;h:panelGrid columns="2" columnClasses="label, value"&gt;
                          &lt;h:outputText value="Email: *" /&gt;
                          &lt;p:inputText required="true" label="Email"
                                       value="#{userWizard.user.email}" /&gt;
  
                          &lt;h:outputText value="Phone: " /&gt;
                          &lt;p:inputText value="#{userWizard.user.phone}"/&gt;
  
                          &lt;h:outputText value="Additional Info: " /&gt;
                          &lt;p:inputText value="#{userWizard.user.info}"/&gt;
                      &lt;/h:panelGrid&gt;
                  &lt;/p:panel&gt;
              &lt;/p:tab&gt;
  
              &lt;p:tab id="confirm" title="Confirmation" &gt;
                  &lt;p:panel header="Confirmation"&gt;
  
                      &lt;h:panelGrid id="confirmation" columns="6"&gt;
                          &lt;h:outputText value="Firstname: " /&gt;
                          &lt;h:outputText styleClass="outputLabel"
                                        value="#{userWizard.user.firstname}" /&gt;
  
                          &lt;h:outputText value="Lastname: " /&gt;
                          &lt;h:outputText  styleClass="outputLabel"
                                         value="#{userWizard.user.lastname}"/&gt;
  
                          &lt;h:outputText value="Age: " /&gt;
                          &lt;h:outputText styleClass="outputLabel"
                                        value="#{userWizard.user.age}" /&gt;
  
                          &lt;h:outputText value="Street: " /&gt;
                          &lt;h:outputText styleClass="outputLabel"
                                        value="#{userWizard.user.street}" /&gt;
  
                          &lt;h:outputText value="Postal Code: " /&gt;
                          &lt;h:outputText styleClass="outputLabel"
                                        value="#{userWizard.user.postalCode}" /&gt;
  
                          &lt;h:outputText value="City: " /&gt;
                          &lt;h:outputText styleClass="outputLabel"
                                        value="#{userWizard.user.city}" /&gt;
  
                          &lt;h:outputText value="Email: " /&gt;
                          &lt;h:outputText styleClass="outputLabel"
                                        value="#{userWizard.user.email}" /&gt;
  
                          &lt;h:outputText value="Phone " /&gt;
                          &lt;h:outputText styleClass="outputLabel"
                                        value="#{userWizard.user.phone}"/&gt;
  
                          &lt;h:outputText value="Info: " /&gt;
                          &lt;h:outputText styleClass="outputLabel"
                                        value="#{userWizard.user.info}" /&gt;
  
  
                      &lt;/h:panelGrid&gt;
  
                      &lt;p:commandButton immediate="true" value="Submit" update="wiz"
                                       actionListener="#{userWizard.save}"  ajax="false"/&gt;
  
                  &lt;/p:panel&gt;
              &lt;/p:tab&gt;
  
          &lt;/p:wizard&gt;
  
  
  
          &lt;p:dataTable var="user" value="#{userWizard.userAll}" id="userList" editable="true" rowKey="#{user.firstname}" paginator="true"
                       rows="4" rowsPerPageTemplate="4,6" &gt;
  
              &lt;p:column headerText="FirstName" style="width:125px" filterBy="#{user.firstname}" sortBy="#{user.firstname}"&gt;
                  &lt;p:cellEditor&gt;
                      &lt;f:facet name="output"&gt;
                          &lt;h:outputText value="#{user.firstname}" /&gt;
                      &lt;/f:facet&gt;
                      &lt;f:facet name="input"&gt;
                          &lt;h:outputText value="#{user.firstname}" /&gt;
                      &lt;/f:facet&gt;
                  &lt;/p:cellEditor&gt;
              &lt;/p:column&gt;
  
              &lt;p:column headerText="LastName" style="width:125px" filterBy="#{user.lastname}" sortBy="#{user.lastname}" &gt;
                  &lt;p:cellEditor&gt;
                      &lt;f:facet name="output"&gt;
                          &lt;h:outputText value="#{user.lastname}" /&gt;
                      &lt;/f:facet&gt;
                      &lt;f:facet name="input"&gt;
                          &lt;p:inputText value="#{user.lastname}" style="width:100%" &gt;
                          &lt;/p:inputText&gt;
                      &lt;/f:facet&gt;
                  &lt;/p:cellEditor&gt;
              &lt;/p:column&gt;
  
              &lt;p:column headerText="Age" style="width:125px" filterBy="#{user.age}" sortBy="#{user.age}"&gt;
                  &lt;p:cellEditor&gt;
                      &lt;f:facet name="output"&gt;
                          &lt;h:outputText value="#{user.age}" /&gt;
                      &lt;/f:facet&gt;
                      &lt;f:facet name="input"&gt;
                          &lt;p:inputText value="#{user.age}" style="width:100%" &gt;
                          &lt;/p:inputText&gt;
                      &lt;/f:facet&gt;
                  &lt;/p:cellEditor&gt;
              &lt;/p:column&gt;
  
              &lt;p:column headerText="Edit" style="width:50px"&gt;
                  &lt;p:rowEditor /&gt;
              &lt;/p:column&gt;
              &lt;p:ajax event="rowEdit" listener="#{userWizard.editRowListner}" update=":form:mymessage"/&gt;
  
          &lt;/p:dataTable&gt;
      &lt;/h:form&gt;
  &lt;/h:body&gt;
  </code></pre>
  
  <p></p>
  
  <p>UserWizard.java</p>
  
  <pre><code>package com.test;
  
  import java.util.ArrayList;
  import java.util.List;
  import java.util.logging.Logger;
  import javax.faces.bean.SessionScoped;
  import javax.faces.application.FacesMessage;
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.ViewScoped;
  import javax.faces.context.FacesContext;
  import javax.faces.event.ActionEvent;
  import org.primefaces.event.FlowEvent;
  import org.primefaces.event.RowEditEvent;
  
  
  @ManagedBean
  @SessionScoped
  
  public class UserWizard {
  
  private User user = new User();
  private boolean skip;
  private List&lt;User&gt; userAll = new ArrayList&lt;User&gt;();
  
  
  private static Logger logger = Logger.getLogger(UserWizard.class.getName());
  /*public UserWizard() {
      userAll = new ArrayList&lt;User&gt;();
  }*/
  public List&lt;User&gt; getUserAll() {
      return userAll;
  }
  
  public void setUserAll(List&lt;User&gt; userAll) {
      this.userAll = userAll;
  }
  public User getUser() {
      return user;
  }
  
  public void setUser(User user) {
      this.user = user;
  }
  
  public void save(ActionEvent actionEvent) {
      //Persist user
      System.out.println("First name : " + user.getFirstname());
      System.out.println("Last name : " + user.getLastname());
      System.out.println("Age name : " + user.getAge());
      userAll.add(user);
      user = new User();
      FacesMessage msg = new FacesMessage("Successful", "Welcome :" + user.getFirstname());
      FacesContext.getCurrentInstance().addMessage(null, msg);
  
  }
  
  public boolean isSkip() {
      return skip;
  }
  
  public void setSkip(boolean skip) {
      this.skip = skip;
  }
  
  public String onFlowProcess(FlowEvent event) {
      logger.info("Current wizard step:" + event.getOldStep());
      logger.info("Next step:" + event.getNewStep());
      System.out.println("First name : " + user.getFirstname());
      System.out.println("Last name : " + user.getLastname());
      System.out.println("Age name : " + user.getAge());
      if (skip) {
          skip = false;   //reset in case user goes back
          return "confirm";
      } else {
  
          return event.getNewStep();
      }
  }
  
  public void editRowListner(RowEditEvent rowEditEvent) {
      try {
          User updatedUser = (User) rowEditEvent.getObject();
          System.out.println("User First Name: " + updatedUser.getFirstname());
          FacesContext context = FacesContext.getCurrentInstance();
          context.addMessage(null, new FacesMessage("Update called", "updated by user"));
      } catch (Exception ex) {
          ex.getMessage();
      }
  }
  }
  </code></pre>
  
  <p>User.java</p>
  
  <pre><code>public class User {
  
  private String firstname;
  private String lastname;
  private Integer age;
  private String street;
  private String city;
  private String postalCode;
  private String info;
  private String email;
  private String phone;
  
  public User(String firstname, String lastname, Integer age, String street, String city, String postalCode, String info, String email, String phone) {
      this.firstname = firstname;
      this.lastname = lastname;
      this.age = age;
      this.street = street;
      this.city = city;
      this.postalCode = postalCode;
      this.info = info;
      this.email = email;
      this.phone = phone;
  }
  
  public User() {
  
  }
  
  public String getFirstname() {
      return firstname;
  }
  
  public void setFirstname(String firstname) {
      this.firstname = firstname;
  }
  
  public String getLastname() {
      return lastname;
  }
  
  public void setLastname(String lastname) {
      this.lastname = lastname;
  }
  
  public Integer getAge() {
      return age;
  }
  
  public void setAge(Integer age) {
      this.age = age;
  }
  
  public String getStreet() {
      return street;
  }
  
  public void setStreet(String street) {
      this.street = street;
  }
  
  public String getCity() {
      return city;
  }
  
  public void setCity(String city) {
      this.city = city;
  }
  
  public String getPostalCode() {
      return postalCode;
  }
  
  public void setPostalCode(String postalCode) {
      this.postalCode = postalCode;
  }
  
  public String getInfo() {
      return info;
  }
  
  public void setInfo(String info) {
      this.info = info;
  }
  
  public String getEmail() {
      return email;
  }
  
  public void setEmail(String email) {
      this.email = email;
  }
  
  public String getPhone() {
      return phone;
  }
  
  public void setPhone(String phone) {
      this.phone = phone;
  }
  }
  </code></pre>