javaprimefacesselectonemenu

how to set to OldValue the primefaces selectOneMenu programmatically


Java / PrimeFaces 3.5

I would like to rollback primeFaces selectOneMenu Old Value and reload it updating the component at screen.

  1. The selectOneMenu is loaded with FIRST, SECOND , THIRD values and default value is setted with FIRST

  2. If I change the selectOneMenu value From FIRST to THIRD, I would like to set it to FIRST again.

    <p:selectOneMenu id="statusProposta"
       value="#{propostaBean.propostaComercial.proposta_Status}"
         items="#{propostaBean.statusProposta}"
         valueChangeListener="#{propostaBean.regraStatusProposta}" >
         <p:ajax  event="change"  
           process="statusProposta" update="statusProposta" />
         <f:selectItem itemLabel="" itemValue="" />
         <f:selectItems value="#{propostaBean.statusProposta}" />
    </p:selectOneMenu>
    

StatusProposta :

public enum StatusProposta { FIRST,SECOND and THIRD .....

Bean :

public void regraStatusProposta(ValueChangeEvent ev){
   **I dont know how to set the old value and update it in screen.**
   ...

Solution

  • http://forum.primefaces.org/viewtopic.php?f=3&t=36447

    resetinput

    blog post: Reset Values for JSF 2.2

    posted by Howard at primefaces forum

    http://www.primefaces.org/showcase/ui/resetInput.jsf

    public void reset() {  
        RequestContext.getCurrentInstance().reset("form:panel");  
    }