0

In my web application there's a page where users can post messages. The problem is a user always has to click a button 'get messages' to see the messages other users have posted since the moment the user started viewing the page. So the information the user is viewing is only up to date from the moment he clicked the button 'get messages' again. How can I accomplish in JSF 2.0 that when an other user deletes, inserts or updates a message, the other users can see these changes directly. One could say I'd like to accomplish something like the Facebook application does: if someone posts new information, his 'friends' can see it directly in their feed without having to push a button. Any help would be greatly appreciated.

I'm using JSF 2.0 and GlassFish Server.

Bart1990
  • 255
  • 2
  • 6
  • 17
  • With HTTP, the server is not allowed to create a connection with a client. Only a client can do a request, so that means you will likely need some kind of javascript thread running in the background which queries from time to time for new messages. Just of the top of my head, I'm thinking you need to keep a timestamp on your client side which, when you query the server, is used to check if the server holds newer messages. If the timestamp has changed, then you do a AJAX request for the new messages. – Nadir Muzaffar Aug 30 '11 at 17:42

1 Answers1

0

You can either do polling or pushing.

Pushing is better. Refer to this thread on how to do it with JSF How can server push asynchronous changes to a HTML page created by JSF?

Community
  • 1
  • 1
bpgergo
  • 15,669
  • 5
  • 44
  • 68
  • Thank you. Searching these terms in Google, I'll probably find some websites with more information. – Bart1990 Sep 02 '11 at 11:58