title: primefaces extension form. Clear form after save or on load
body: <p>i have build a primefaces extensions wizard like form with steps, using component  shown here:</p>
  
  <p><a href="http://fractalsoft.net/primeext-showcase-mojarra/sections/masterDetail/wizardLikeNavigation.jsf" rel="nofollow">http://fractalsoft.net/primeext-showcase-mojarra/sections/masterDetail/wizardLikeNavigation.jsf</a></p>
  
  <p>My back bean is View Scoped however when i complete the steps and save the form, on subsequent  form loads it does not get refreshed cleared (the values i have selected in the first time i submitted the form are still present) ...</p>
  
  <p>My command button is at the end of my wizard panel code which is the following:</p>
  
  <pre><code>&lt;h:form id="WizardForm"&gt;            
  &lt;pe:masterDetail id="masterDetail" level="#{reviewWizard.currentLevel}" showBreadcrumb="false" style="margin-top:20px"&gt; 
      &lt;f:facet name="header"&gt;
      ...
      &lt;/f:facet&gt;
      &lt;pe:masterDetailLevel level="1"&gt;        
      &lt;p:dataTable id="patients" var="patient"
                  value="#{reviewWizard.cRImageDataListPatients}"
                  selection="#{reviewWizard.selectedPatients}" rowKey="#{patient}"
                  paginator="true" rows="10" paginatorAlwaysVisible="false"
                  emptyMessage="No records found" &gt;
          &lt;p:ajax event="rowToggle" listener="#{reviewWizard.onRowToggle}"
                  update=":WizardForm:patients:selectedPatientImages" /&gt;
          &lt;f:facet name="header"&gt; 
              Select one or many images using the checkboxes and press &amp;quot;Next&amp;quot; button to proceed.  
          &lt;/f:facet&gt;
          &lt;p:column selectionMode="multiple" style="width:18px" styleClass="mandara"/&gt;
          &lt;p:column style="width:18px"&gt;
          &lt;p:rowToggler /&gt;
          &lt;/p:column&gt;
          &lt;p:column headerText="Patient ID"&gt;  
          #{patient}  
          &lt;/p:column&gt;                     
              &lt;p:rowExpansion&gt;
              &lt;p:dataTable id="selectedPatientImages" var="cRImageData"
                      value="#{reviewWizard.getSelectedPatientImages()}"
                      rowKey="#{cRImageData.imId}" emptyMessage="No records found"
                      style="padding:10px 40px;"&gt;
                  &lt;p:column headerText="Image Name"&gt;  
                  #{cRImageData.imName}  
                  &lt;/p:column&gt;
                  &lt;p:column headerText="Image Type"&gt;  
                  #{cRImageData.imType}  
                  &lt;/p:column&gt;
                  ...                 
              &lt;/p:dataTable&gt;
              &lt;/p:rowExpansion&gt;
              ...
              &lt;/p:dataTable&gt;
          &lt;p:commandButton value="Next" process="masterDetail" style="margin-top: 10px;" icon="ui-icon-arrowthick-1-e"&gt;
          &lt;pe:selectDetailLevel step="1"/&gt;
          &lt;/p:commandButton&gt;
      &lt;/pe:masterDetailLevel&gt;
      &lt;pe:masterDetailLevel level="2"&gt;
      ... 
      &lt;/pe:masterDetailLevel&gt;
      &lt;pe:masterDetailLevel level="3"&gt;
      ...
      &lt;/pe:masterDetailLevel&gt;    
      &lt;pe:masterDetailLevel level="4"&gt;        
          ...
      &lt;/pe:masterDetailLevel&gt;
      &lt;pe:masterDetailLevel level="5"&gt;        
              &lt;p:panel header="Confirmation"&gt;            
              &lt;p:panel style="border:none;"&gt;
                  &lt;h:outputText value="Selected Patients: " style="font-weight:700;"/&gt;
                  &lt;h:outputText value="#{reviewWizard.getSelectedPatiensString()}" /&gt;
              &lt;/p:panel&gt;      
              &lt;p:panel style="border:none;"&gt;      
                      &lt;h:outputText value="Selected Features: "  style="clear:left;font-weight:700;"/&gt;
                      &lt;h:outputText value="#{reviewWizard.getSelectedFeaturesString()}" /&gt;
              &lt;/p:panel&gt;      
              &lt;p:panel style="border:none;"&gt;
                      &lt;h:outputText value="Selected Reviewers: "  style="clear:left;font-weight:700;"/&gt;
                      &lt;h:outputText value="#{reviewWizard.getSelectedReviewersString()}" /&gt;
              &lt;/p:panel&gt;      
              &lt;p:panel style="border:none;"&gt;
                      &lt;h:outputText value="Protocol Description: "  style="clear:left;font-weight:700;"/&gt;
                      &lt;h:outputText value="#{reviewWizard.getReviewProtocolDesc()}" /&gt;
              &lt;/p:panel&gt;        
                     &lt;p:commandButton value="Back" style="margin-top: 10px;" icon="ui-icon-arrowthick-1-w"  
                       process="@this" immediate="true"&gt;  
                          &lt;pe:selectDetailLevel step="-1"/&gt;  
                     &lt;/p:commandButton&gt;  
                     &lt;p:commandButton value="Submit" process="masterDetail"  
                       actionListener="#{reviewWizard.save}"  
                       style="margin-top: 10px;" icon="ui-icon-disk"&gt;
                          &lt;pe:selectDetailLevel level="1" resetInputs="@all"/&gt;  
                      &lt;/p:commandButton&gt;        
               &lt;/p:panel&gt;
      &lt;/pe:masterDetailLevel&gt; 
  &lt;/pe:masterDetail&gt;          
  &lt;/h:form&gt;
  </code></pre>
  
  <p>And my back bean (create new empty object at the end of the 'save' action, as suggested in primefaces extensions relative example):</p>
  
  <pre><code>ManagedBean(name = "reviewWizard")
  @ViewScoped
  public class ReviewWizard implements Serializable {
  
  private static final long serialVersionUID = -7410916604435445849L;
  
  private List&lt;String&gt; cRImageDataListPatients;
  private List&lt;CRImageData&gt; cRImageDataListPatientImages;
  private CRImageData[] selectedImages;
  private String[] selectedPatients;
  
  private List&lt;CRVariable&gt; availableCRVariables;  
  private CRVariable[] selectedVariables;
  
  private CRReviewProtocol reviewProtocol;
  private String reviewProtocolDescription;
  
  private List&lt;User&gt; availableReviewers;
  private User[] selectedReviewers;
  
  private List&lt;CRReviewerData&gt; availableReviewersInternal;
  private CRReviewerData[] selectedReviewerInternal;
  
  private CRTask[] cRTask;
  
  private int currentLevel = 1;   
  
  // Logger   
  private static Logger logger = Logger.getLogger(ReviewWizard.class.getName());
  private static final String SUCCESS = "success";
  private static final String ERROR   = "error";
  
  //on report form load do
  @SuppressWarnings("unchecked")
  @PostConstruct
  public void init(){
  
      //call SOAP service to UPM to fetch patients
      CallWebService callWebService = new CallWebService();
      cRImageDataListPatients = callWebService.call("PatientIds");
  
      availableCRVariables = getCRVariables();
  
      // Set selectedImages to avoid null pointer exceptions
      selectedImages = new CRImageData[0];
      selectedPatients = new String[0];
      selectedVariables = new CRVariable[0];
  
      try {
          availableReviewers = getReviewers();
          } catch (PortalException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } catch (SystemException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
      }
  
      selectedReviewers = new User[0];                
      reviewProtocolDescription = new String() ;
      setSelectedReviewerInternal(new CRReviewerData[0]);
  }
  
  //on save report form do
  public void save(ActionEvent actionEvent) {
      String result = null;       
  
      List&lt;CRVariable&gt; mySelectedVariables = Arrays.asList(selectedVariables);
      List&lt;String&gt; mySelectedPatients = Arrays.asList(selectedPatients);
      List&lt;User&gt; mySelectedReviewers = Arrays.asList(selectedReviewers);
      List&lt;CRReviewerData&gt; mySelectedReviewersInternal = transformLusers(mySelectedReviewers);        
  
      Date now = new Date();
  
      Session session = HibernateUtil.getSessionFactory().openSession();
  
      CRReviewProtocol reviewProtocol = new CRReviewProtocol();
  
      reviewProtocol.setRevProtDescription(this.getReviewProtocolDescription());      
      reviewProtocol.setCrimagedata(mySelectedPatients);
      reviewProtocol.setCrvariables(mySelectedVariables);     
      reviewProtocol.setcRReviewerData(mySelectedReviewersInternal);
  
      Transaction tx = null;
      try 
      {
          tx = session.beginTransaction();
          session.save(reviewProtocol);
          tx.commit();
          logger.debug("New Record :" + reviewProtocol + ", wasCommitted : " + tx.wasCommitted());
          result = SUCCESS;
      } 
      catch (Exception e) 
      {
          if (tx != null) 
          {
              tx.rollback();
              result = ERROR;
              e.printStackTrace();
          }
      } 
      finally 
      {
         //session.close();
      }
  
      infoMsg("Successful", "The Review Protocol has been succesfully created!");
  
      for(int j=0;j&lt;mySelectedPatients.size();j++){
  
          System.out.println("&gt;&gt;&gt;&gt; For patient " + j + " with id " + mySelectedPatients.get(j));
          List&lt;CRImageData&gt; patientImages = getPatientImages(mySelectedPatients.get(j));
  
          for (int k=0;k&lt;patientImages.size();k++){
  
              System.out.println("&gt;&gt;&gt; For image with id " + patientImages.get(k).getImId());
  
              for(int i=0;i&lt;mySelectedReviewersInternal.size();i++){
  
                  System.out.println("&gt;&gt;&gt;&gt; For reviewer with id: " + mySelectedReviewersInternal.get(i).getUserEmail());
  
                  CRTask cRTask = new CRTask();
  
                  cRTask.setcRReviewProtocol(reviewProtocol);
                  cRTask.setStatus("Open");
                  cRTask.setDescription("Default description");
                  cRTask.setCreationDate(now);
                  cRTask.setReviewerId(mySelectedReviewersInternal.get(i).getUserId());
                  cRTask.setPatientId(mySelectedPatients.get(j));
                  cRTask.setImageId(patientImages.get(k).getImId());
  
                  System.out.println("&gt;&gt;&gt;&gt;&gt; task object created");
  
                  try 
                  {
                      tx = session.beginTransaction();
                      session.save(cRTask);
                      tx.commit();
                      logger.debug("New Record :" + cRTask + ", wasCommitted : " + tx.wasCommitted());
                      result = SUCCESS;
                  } 
                  catch (Exception e) 
                  {
                      if (tx != null) 
                      {
                          tx.rollback();
                          result = ERROR;
                          e.printStackTrace();
                      }
                  }
          }
          }
      }
      //}
      //finally 
      //{
         session.close();
      //}
  
      //create an empty review protocol   
      CRImageData[] selectedImages = new CRImageData[0];
      String[] selectedPatients = new String[0];
      CRReviewProtocol reviewProtocol1 = new CRReviewProtocol();
      ReviewWizard reviewWizard = new ReviewWizard(); 
      currentLevel=1;     
  }
  
  public ReviewWizard(){  
  
  }
  
  //method to transform user object to crreviewerdata
  public List&lt;CRReviewerData&gt; transformLusers(List&lt;User&gt; selectedReviewers){
  
      List&lt;CRReviewerData&gt; selectedReviewersInternal = new ArrayList&lt;CRReviewerData&gt;();
  
      for(int i=0;i&lt;selectedReviewers.size();i++){
  
          CRReviewerData selectedReviewerInternal = new CRReviewerData();
          selectedReviewerInternal.setUserId(selectedReviewers.get(i).getUserId());
          selectedReviewerInternal.setUserFname(selectedReviewers.get(i).getFirstName());
          selectedReviewerInternal.setUserLname(selectedReviewers.get(i).getLastName());
          selectedReviewerInternal.setUserEmail(selectedReviewers.get(i).getEmailAddress());
          selectedReviewersInternal.add(selectedReviewerInternal);            
      }       
      return selectedReviewersInternal;   
  }
  </code></pre>
  
  <p>Any ideas of what i have been missing?</p>