JSF backing beans are not Controllers. They are Models.
You should not use valueChangeListeners to capture data. If the submitted form has validated data, JSF will automatically update the backing bean (Model) properties without any need for you to code for it. You can then use the action method to talk to the database.
When you submit a form using JSF, and your action method does not direct JSF to navigate to a new page, the same page will be redrawn using the updated Model values. If you are instead using AJAX to do a partial-page submit, you must tell the AJAX mechanism what parts of the page to refresh.
Binding is something that should not be used casually, despite what a lot of old out-of-date documentation might make you believe. The primary use for binding is cases where the model is actively modifying View UI, and that's not something that should be done too freely.
Customer surveys are for companies who didn't pay proper attention to begin with.
Joined: Sep 13, 2011
My problem is exactly as describe in you statement
the model is actively modifying View UI,
I have a requirement exactly as that and I want the UI datatable to be refreshed with the changed information after I process it.
I am using a value change listener only to capture the changed records on the UI.
So , say I have a screen with a datatable displaying user information , and there is radio button group to update his status ( viz Active/Inactive/NA) .
1)When for a user, one of those radio buttons is selected (this could done multiple users on the screen) and the a button called Update Changes is clicked,
2) I am capturing the changed rows of the datatable using getRowData()( this datatable is bound to the one on UI) in valuechange listener method of the radio button,
3)process those two and render the page back.
I do not knw if there is a btter way for 1 and 2.
However my problem is after 3. When the page is render the processed items have few field values that were upated fro teh DB(status etc) and I need the datatable to reflect it. By doing nothing after 3 , the screen is not refreshing the new info.
I'm afraid you misinterpreted that. When I said "modifying the UI" I meant wholesale changes where you actually add or remove entire controls from the web page. Updating the contents of a UI control is not sufficient reason for using binding. Changing the control layout on a GUI can confuse the user, so it's not recommended in most cases, so therefore neither is binding.
The UI (View) is updated by the Controller (FacesServlet) when the Model (backing bean) has been changed and an HTTP submit request is made from the client to the server. Sub-Views (such as dataTables) are updated from their corresponding Sub-Models (TableModels). As long as the model mapping was configured properly in the View Definition, no programmer-supplied code is required.