Thursday, August 25, 2016

ADF: Update model in value change listener

There are some cases when we need to get a value associated to the new value that we have selected in a selectOneChoice, or that we have typed in an inputText.
In this cases we will not be able to get that value, as the only thing we can do is to get the new value from the ValueChangeListener object.

In this example we are going to use HR schema and we will have Employees view object. In DepartmentId field we are going to create a List of Values to show the DepartmentName value in the selectOneChoice.


We are also going to add DepartmentName field from Departments view into Employees view.


If we have to drag and drop the Employees view from the data control palette into our page and create a form.

In DepartmentId field component, we have to set autoSubmit to true and create a valueChangeListener.


If we print the values in the method. To get the value from the attribute bindings I am using resolveExpression method that can be found in JSFUtils class.


We can see that the model value will be always the previously selected value.


To display the new value associated to the selected one, we need to force the update model calling procesUpdates method.


If we run again the application we can see that the selected value is displayed.




No comments:

Post a Comment