• Post Reply Bookmark Topic Watch Topic
  • New Topic

dynamically rerender datatable content from managedbean?  RSS feed

 
chaowang wangchao
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I'm using Richfaces to develop some web pages, with a datatable I try to display some data information from remote server. But its quite slow to load all data in one time, so I use a cache to store data, Firstly my cache is empty and data table is empty.

The ideal goal is loading one row from server and store into my cache, then append into data table's end, my question is how can I render the content of data table from managedbean once I retrieve some new data into cache?

Thanks,
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HTTP, you cannot update a web page asynchronously, because HTTP does not support unsolicited responses without matching requests. However, you can use AJAX to submit a series of requests to update a table display periodically.

Consider, however, that J2EE server-side resources are not independent programs running asynchronously, however, they are resource invoked in response to an HTTP request and sit idle when a request/response cycle is not active. To get a long-running update going, you'd need a separate thread to continue processing after the response that did the initial table display was sent back. However, the J2EE standard explicitly forbids request-handler code from creating threads.

To get around this problem, you can construct a "processing engine" thread in a ServletContext listener (at webapp startup time). It should sit idle until needed, then run in response to client needs. For example, in your case, a request would notify the engine to start processing and to pick up and the initial display table rows to the request processor. Later (AJAX) requests would then poll the engine for additional data. If you have a lot of clients, you might also have a "master engine" that spawns child engine threads, one per client. Note that since this is all work being done outside of the thread that processes the actual web requests, you'll generally have to use synchronized objects and methods to talk to the engine.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!