jQuery in Action, 2nd edition*
The moose likes JSF and the fly likes Automatically refresh datatable when Session Bean changes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Automatically refresh datatable when Session Bean changes" Watch "Automatically refresh datatable when Session Bean changes" New topic
Author

Automatically refresh datatable when Session Bean changes

Michael Cook
Greenhorn

Joined: Nov 06, 2008
Posts: 5
I have an JSF application that uses a data table (i.e. <h:datatable>) to display the values inside of a Session Bean (via a Backing Bean). The problem I have is that the Session Bean is continuously being updated on the server. The data table needs to reside on the client side for manipulation purposes (e.g. sorting, filtering, hide/show columns)

How do I manage to push these changes to my data table?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
It sounds like that you´re using entirely Javascript for sorting/filtering/hiding/showing without re-requesting the data from the server side. In this case, you can´t do anything but polling for the server for new data. HTTP disallows pushing data to the client, so you can´t do any much from the server side on.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16093
    
  21

Bauke Scholtz wrote: HTTP disallows pushing data to the client, so you can´t do any much from the server side on.


Which is why true MVC is impossible via HTTP. In true MVC, asynchronous changes to the Model will cause the Controller to update the View. Since HTTP is strictly request/response, the view can only be updated when a new request is made - either by an explicit action or by having client-side polling - the HTTP standard strictly forbids unsolicited responses. In fact, without a request, the very word "response" is meaningless, since it's a reactive word, not an active one.

Still, the nice thing about JSF is that it's about as close to true MVC as HTTP will let you get.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
GeeCON Prague 2014
 
subject: Automatically refresh datatable when Session Bean changes