如何以编程方式将oldValue设置为selectOneMenu

时间:2014-02-17 14:03:08

标签: java primefaces selectonemenu

Java / PrimeFaces 3.5

我想回滚primeFaces selectOneMenu Old Value并重新加载它在屏幕上更新组件。

  1. selectOneMenu加载了FIRST,SECOND,THIRD值,默认值设置为FIRST

  2. 如果我将selectOneMenu值从FIRST更改为THIRD,我想再次将其设置为FIRST。

    <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>
    
  3. StatusProposta:

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

    Bean:

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

2 个答案:

答案 0 :(得分:0)

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

More on ValueChangeEvent API

答案 1 :(得分:0)

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

resetinput

博客文章:重置JSF 2.2的值

霍华德在primefaces论坛上发表了

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

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