Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Firstly, you'll need to expose the url for your event handler:</p> <pre><code>public String getModeChangedUrl() { // will call the onModeChanged method return resources.createEventLink("ModeChanged").toAbsoluteURI(); } </code></pre> <p>Then, in a javascript block in your tml assign the url to a variable:</p> <pre><code>var modeChangedUrl = "${modeChangedUrl}"; </code></pre> <p>Then you need to get a handle to a ZoneManager javascript object:</p> <pre><code>var zm = Tapestry.findZoneManagerForZone(zoneId); </code></pre> <p>It's not important which zone you get the ZoneManager for, all this does is facilitate the ajax callback. If the event listener returns a MultiZoneUpdate or an update for a different zone, it will be handled correctly.</p> <p><em>I use a dummy zone for marshalling and always return a MultiZoneUpdate even if I'm only updating one zone. Since more often than not I need to update multiple zones, I find it easier to be consistent in my approach. anyway, that is a little off topic for your question.</em></p> <p>if you have additional parameters for the event handler, you can append them to the url separated by '/' ie "http://www.host.com/app/page/event/param1/param2"</p> <p>now that you have the <code>url</code> and a <code>ZoneManager</code>, you can initialise the request-response loop:</p> <pre><code>zm.updateFromURL(url); </code></pre> <p>as henning suggested, combining this with the <a href="http://www.prototypejs.org/api/periodicalExecuter" rel="nofollow">PeriodicalExecuter</a> in prototype will achieve what you want:</p> <pre><code>new PeriodicalExecuter(function(pe) { var zm = Tapestry.findZoneManagerForZone("anyZoneId"); zm.updateFromUrl(url); }, 5); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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