How to reset the style wizard steps?

i use the step-by-step settings <p:wizard>and i, step by step. If the registration is completed successfully, the wizard step is performed first, but if I continue the new recording or the user, the Wizard will not be able to add a new recording. This is an update to the previous entry / instead. How to add new entries? Another problem; when he returns to the first step, he cannot reset the field. How can i do this? its submit button code;

<p:commandButton immediate="true" value="Submit" update="@parent,wiz1,growl,panel"
                            actionListener="#{OgrenciKayit.save}" oncomplete="wiz.loadStep (wiz.cfg.steps [0], true)" />

he returns to the first step if the master is sent.

oncomplete="wiz.loadStep (wiz.cfg.steps [0], true)"

and actionListener

public void save(ActionEvent actionEvent) {
        tx = session.beginTransaction();
        session.save(ogrenci);
        tx.commit();
        FacesMessage msg = new FacesMessage("Başarılı", "Hoşgeldin :"
                + ogrenci.getAd());
        FacesContext.getCurrentInstance().addMessage(null, msg);
    }

Waiting for your ideas .. (additional information I use Jsf 2.2, Tomcat 7.0.50, Hibernate 4.3.5.final, Primefaces, Shiro)

+4
3
org.primefaces.context.RequestContext

RequestContext context = RequestContext.getCurrentInstance();
context.reset("myForm");
+2
<p:wizard widgetVar="wiz">
   <p:tab id="tab0">  ...  </p:tab>
   <p:tab id="tab1"> ...
      <p:commandButton value="Jump to tabId"
          actionListener="#{actionTodo.jump}"
          oncomplete="PF('wiz').loadStep('tab0', false)" />
   </p:tab>
 </p:wizard>

PrimeFaces 5.0. , tabId loadStep. PF "PF('widgetVarId')".

+6
public void save(ActionEvent actionEvent) {
    tx = session.beginTransaction();
    session.save(ogrenci);
    tx.commit();
    FacesMessage msg = new FacesMessage("Başarılı", "Hoşgeldin :"
            + ogrenci.getAd());
    FacesContext.getCurrentInstance().addMessage(null, msg);

ogrenci = new Ogrenci ();

}
-1
source

Source: https://habr.com/ru/post/1541083/


All Articles