Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Okay... What you're asking is a little fuzzy so let me rephrase: </p> <ul> <li><p>You have a user (USER1) who opens a web page and sees some data.</p></li> <li><p>You have a second user (USER2) (who may be an application) who is able set a value from time to time.</p></li> <li><p>When USER2 updates that value you want USER1 to see it change in their open browser window?</p></li> </ul> <p>If this is the case you need to understand basic ajax. For that get these demo applications working: </p> <p>This example uses dojo and perhaps the S2 ajax tag lib I don't remember I prefer not to use ajax tags (as they are deprecated and prefer jquery for ajax):</p> <p><a href="http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html" rel="nofollow">http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html</a></p> <p>This example here shows a very similar application but using jquery, no tag library, upgraded to Spring 3, it still needs polish:</p> <p><a href="http://www.kenmcwilliams.com/Downloads/" rel="nofollow">http://www.kenmcwilliams.com/Downloads/</a></p> <p>Now that you know how to get data via ajax, look at the request with firebug. You'll see that the request is just like a typical function call, the browser keeps waiting for the data to come back.</p> <p>What you do is simply not return from the action until new data is provided. This is called <em>long polling</em> see: <a href="http://en.wikipedia.org/wiki/Comet_%28programming%29#Ajax_with_long_polling" rel="nofollow">http://en.wikipedia.org/wiki/Comet_%28programming%29#Ajax_with_long_polling</a> </p> <p>If you have not written a simple chat program, using just terminal windows I recommend you do so. Two windows per client (client-send, client-receive windows) and you'll need a server program. I remember hacking one together in a few hours using _Thinking In Java 2nd Edition (Later books took out the networking section if I remember correctly). Anyways between understanding client server interaction and long polling will let you get things working. It would be fun to extend the simple terminal based chat application to a S2 ajax chat application. Would make an awesome tutorial! PS: This is just an application of the producer/consumer problem (If you understand that then I guess you don't need to do the fun exercise).</p> <p>The interfaces would look very pretty if the server was managed by spring. I know there must be nice servers already written but I am not familiar with any, but would love to hear of one.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload