How to get updated model values ​​in valueChangeListener method?

I am stuck in a problem with valueChangeListener. I am using JSF 1.2 in Weblogic 6.0.

I have a page where at the top of the page there are 2 radio buttons named Name1 and Name2. When the Name1 button is pressed, the Name1 signatures are displayed after the switches (there are about 30 fields), and when the Name2 button is pressed, the Name2 data is displayed. The user can now update the data below. for example, the user clicks on Name1 and changes the address field, and then clicks on Name2 and changes the age of Name2. When the user presses "Name1", the address should be updated with a new value and again, when the user clicks on Name2, the age should be updated.

I used valueChangeListener to solve it, because I need the old and new value of the changed event. The problem is that since valueChangeListener is called at the end of the VALIDATION phase, I do not get the updated address of the Name1 field in the valueChangeListener method. Can someone help me to get some workaround?

+7
source share
1 answer

since valueChangeListener is called at the end of the VALIDATION phase, I do not get the updated address of the Name1 field in the valueChangeListener method

The event queue in the INVOKE_ACTION phase so that it acts as an action (listener) method.

 public void valueChangeListenerMethod(ValueChangeEvent event) { if (event.getPhaseId() != PhaseId.INVOKE_APPLICATION) { event.setPhaseId(PhaseId.INVOKE_APPLICATION); event.queue(); return; } // Do your original job here. // It will only be entered when current phase ID is INVOKE_APPLICATION. } 

As the INVOKE_ACTION phase starts after UPDATE_MODEL_VALUES , updated model values ​​will only be available in the "normal way".

+14
source

All Articles