aspose file tools*
The moose likes JSF and the fly likes Datatable Refresh Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Datatable Refresh Issue" Watch "Datatable Refresh Issue" New topic
Author

Datatable Refresh Issue

Hari Gundappa
Greenhorn

Joined: Sep 13, 2011
Posts: 27
Hi,

I have a screen with a datatable that has binding to a controller.

When user clicks on some radio buttons on the ui and saves, the a valuechange listener on the radio ,get the changed objects in the controller and updates
to the DB.

It is after this I have an issue to refresh the db with changed list. The list of objects i the datatable is retained as is, even though I refreshed 2 objects from DB with changed status.

Can some one help me with, how to refresh the changed list of objects to the datatable on the screen?

Thanks,
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

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.
Hari Gundappa
Greenhorn

Joined: Sep 13, 2011
Posts: 27
Thanks Tim.

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.

Hence I need some inputs to adress this.

Please Advise.

Thanks
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Datatable Refresh Issue