jqueryajaxhibernatejsfprimefaces

how to reset primefaces wizard's steps?


i use primefaces <p:wizard> and i registiration step by step.if registiration is end succesfully,wizard's step is first but if i go on for new record or user,Wizard can not add new record.İt is updating previous record/user instead.How do I add new records in series? Another problem; when it returned to the first step,it can not to reset the field.how can i do that? its submit button's code;

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

its returned to the first step if wizard submitted.

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)


Solution

  • org.primefaces.context.RequestContext
    
    RequestContext context = RequestContext.getCurrentInstance();
    context.reset("myForm");