You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by bu...@apache.org on 2017/04/08 12:20:02 UTC

svn commit: r1010038 - in /websites/production/tapestry/content: ajax-and-zones.html cache/main.pageCache

Author: buildbot
Date: Sat Apr  8 12:20:02 2017
New Revision: 1010038

Log:
Production update by buildbot for tapestry

Modified:
    websites/production/tapestry/content/ajax-and-zones.html
    websites/production/tapestry/content/cache/main.pageCache

Modified: websites/production/tapestry/content/ajax-and-zones.html
==============================================================================
--- websites/production/tapestry/content/ajax-and-zones.html (original)
+++ websites/production/tapestry/content/ajax-and-zones.html Sat Apr  8 12:20:02 2017
@@ -271,7 +271,7 @@ void onActionFromRegister()
     return result;
   }
 </pre>
-</div></div><p>This presumes that <code>findByPartialAccountName()</code> will sort the values, otherwise you will probably want to sort them. The Autocomplete mixin does <em>not</em> do any sorting.</p><p>You can return an object array, a list, even a single object. You may return objects instead of strings ... and <code>toString()</code> will be used to convert them into client-side strings.</p><p>&#160;</p><h2 id="AjaxandZones-Invokingserver-sideeventhandlermethodsfromJavaScript">Invoking server-side event handler methods from JavaScript</h2><p>Tapestry 5.4.2 introduced has an API which makes it easy for server-side events to be invoked from JavaScript. In the server-side, you first need to annotate the event handler methods you want exposed with the new&#160;<code>@PublishEvent</code>&#160;annotation. Then, in JavaScript, all you need to do is to call the existing&#160;<code><a  class="external-link" href="http://tapestry.apache.org/current/coffeescript/ajax.html">t5/core/ajax</
 a></code>&#160;function but with slightly different parameters.</p><p><code>t5/core/ajax</code> has two parameters:&#160;<code>url</code> and&#160;<code>options</code>. The first one was the difficult part to get when doing AJAX requests to event handler methods in Tapestry. You needed to inject <code>ComponentResources</code>, call&#160;<code>componentResources.createEventLink()</code> for each event handler method then pass all this information to JS through one of the&#160;<code>JavaScriptSupport</code> methods. Since 5.4.2, your JavaScript code only needs to know the event name (also called <em>event type</em>) and optionally indicate a DOM element to be used as a starting point for finding the event URL.</p><p>All event data is stored in&#160;<code>data-componenent-events</code> attributes. For page classes, it's put in the&#160;<code>&lt;body&gt;</code> element. For components, it's put in the first element rendered created by rendering the component. Given an HTML element, th
 e search is done until one in this order until information for the given event is first found:</p><ol><li>The element itself</li><li>The element's previous siblings, closest first (bottom-up)</li><li>The element's parents.</li><li>The page's &lt;<code>body&gt;</code> element<code>.</code></li></ol><p>&#160;</p><p>Here's one example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>This presumes that <code>findByPartialAccountName()</code> will sort the values, otherwise you will probably want to sort them. The Autocomplete mixin does <em>not</em> do any sorting.</p><p>You can return an object array, a list, even a single object. You may return objects instead of strings ... and <code>toString()</code> will be used to convert them into client-side strings.</p><p>&#160;</p><h2 id="AjaxandZones-Invokingserver-sideeventhandlermethodsfromJavaScript">Invoking server-side event handler methods from JavaScript</h2><p>Tapestry 5.4.2 introduced an API which makes it easy for server-side events to be invoked from JavaScript. On the server-side, you first need to annotate the event handler methods you want to expose with the&#160;<code>@PublishEvent</code>&#160;annotation. Then, in JavaScript, all you need to do is to call the existing&#160;<code><a  class="external-link" href="http://tapestry.apache.org/current/coffeescript/ajax.html">t5/core/ajax</a></co
 de>&#160;function, but with slightly different parameters.</p><p><code>t5/core/ajax</code> has two parameters:&#160;<code>url</code> and&#160;<code>options</code>. The first one was the difficult part to get when doing AJAX requests to event handler methods in Tapestry. You needed to inject <code>ComponentResources</code>, call&#160;<code>componentResources.createEventLink()</code> for each event handler method then pass all this information to JS through one of the&#160;<code>JavaScriptSupport</code> methods. Since 5.4.2, your JavaScript code only needs to know the event name (also called <em>event type</em>) and optionally indicate a DOM element to be used as a starting point for finding the event URL.</p><p>All event data is stored in&#160;<code>data-componenent-events</code> attributes. For page classes, it's put in the&#160;<code>&lt;body&gt;</code> element. For components, it's put in the first element rendered created by rendering the component. Given an HTML element, the sea
 rch is done until one in this order until information for the given event is first found:</p><ol><li>The element itself</li><li>The element's previous siblings, closest first (bottom-up)</li><li>The element's parents.</li><li>The page's &lt;<code>body&gt;</code> element<code>.</code></li></ol><p>&#160;</p><p>Here's one example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class PublishEventDemoComponent
 {
     @OnEvent("answer")

Modified: websites/production/tapestry/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.