File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF page refresh triggered from database

 
nikola petanjak
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

can someone give me clue how to refresh JSF 1.2 page when database table gets updated? Alternative is also, that onMessage method in message bean trigger page refresh.

Thanks in advance.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17629
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTTP is a request/response protocol and JSF is built on top of HTTP. What request/response means is that HTTP servers cannot output data (responses) unless a request was made first. There is a strict 1:1 correspondence between requests and responses, and no request may have multiple responses, nor may the server send unsolicited or asynchronous responses.

So in order to get a page refreshed when a database changes, you must design the webpage to be self-requesting. There's an HTML META tag that can cause the user's browser to send a request after a defined time interval has expired. AJAX can do that as well, but you said "page refresh", not "page update", so I'm going for the simpler solution here.

Likewise, the JSF server-side logic is invoked only on request, so a database cannot simply post updates to the data, the JSF logic has to issue a query to the database when the request has been made. Whether it's easier and more efficient to simply make the same SQL request over and over or attempt something fancier depends on your overall app and database infrastructures. Often the overhead for repeated queries is pretty low, since the unchanged data would be in cache either on the DBMS server, in the webapp, or both places.
 
nikola petanjak
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim, and thank you for your reply.

The problem is, our customer would like fancy solution. I would like to know is it possible to do that kind of refreshing/updating?
In my actual problem, i'd need to update few tables on page after new database update. Can i use ajax with jsf1.2?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17629
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use AJAX with JSF 1.x, yes. Although it's not an integral part of JSF like it is in JSF2, there are several ways to do AJAX in JSF1.

You can do brute-force JavaScript AJAX, if you like to punish yourself.

You can use a system like jQuery to handle the AJAX.

You can use an AJAX-aware extension tag library. RichFaces and IceFaces are 2 popular ones that provide AJAX support that works under JSF 1.1 and 1.2.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic