Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 501
erginduran Avatar asked May 19 '14 08:05

erginduran


2 Answers

<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>

This works for me on PrimeFaces 5.0. Note you just need to provide the tabId to loadStep method. Also we should call PF with "PF('widgetVarId')".

like image 149
Marius Cirstea Avatar answered Oct 20 '22 03:10

Marius Cirstea


org.primefaces.context.RequestContext

RequestContext context = RequestContext.getCurrentInstance();
context.reset("myForm");
like image 3
Merphys Avatar answered Oct 20 '22 01:10

Merphys