문제

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.**
   ...
도움이 되었습니까?

해결책 2

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");  
}  

다른 팁

public void regraStatusProposta(ValueChangeEvent ev){    
//get old value first 
Object oldValue=ev.getOldValue();    
}

More on ValueChangeEvent API

I've created this utility for PrimeFaces which checks if the component is visible, otherwise it would log a WARN on console.

public static void resetUIComponents(String... componentsId) {
    for (String id : componentsId) {
        if (FacesContext.getCurrentInstance().getViewRoot().findComponent(id) != null) {
            PrimeFaces.current().resetInputs(id);
        }
    }
}

So you can use it like this:

ViewUtils.resetUIComponents("form:id1", "form:id2")
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top