jspjsfjsf-1.2valuechangelistener

submitting form when using ValueChangeListener


i have a value change listener for a selectOneMenu,which is a drop down. In our application when i change the value of the drop down, the new form values gets loaded by calling the action listener.

its works perfectly by using the following code in the change listener

public void methodname(ValueChangeEvent e){
    PhaseId phaseId = event.getPhaseId();
    if (phaseId.equals(PhaseId.ANY_PHASE)) {
        event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
        event.queue();
     }   
..............
}

but before loading new form data for the new drop down value. we also need to submit the old drop down value's form and perform validations and persist values in data base for the old drop down value.

is there any way to submit the form to the server for the old drop down value?.

any help is appreciated. if my question is not clear i will try to make it much more clear. thanks in advance


Solution

  • The ValueChangeEvent has two functions for retreiving data getOldValue() and getNewValue().

    So if you want to retreive the previous value, use getOldValue().