• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Datatable Refresh Issue

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hari Gundappa
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic