You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by an...@apache.org on 2008/01/20 03:46:32 UTC

svn commit: r613500 - in /tapestry/tapestry4/trunk/src/site/apt/ajax: eventlistener.apt responsebuilder.apt

Author: andyhot
Date: Sat Jan 19 18:46:31 2008
New Revision: 613500

URL: http://svn.apache.org/viewvc?rev=613500&view=rev
Log:
TAPESTRY-2065: Document addStatusMessage

Modified:
    tapestry/tapestry4/trunk/src/site/apt/ajax/eventlistener.apt
    tapestry/tapestry4/trunk/src/site/apt/ajax/responsebuilder.apt

Modified: tapestry/tapestry4/trunk/src/site/apt/ajax/eventlistener.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/src/site/apt/ajax/eventlistener.apt?rev=613500&r1=613499&r2=613500&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/src/site/apt/ajax/eventlistener.apt (original)
+++ tapestry/tapestry4/trunk/src/site/apt/ajax/eventlistener.apt Sat Jan 19 18:46:31 2008
@@ -13,7 +13,7 @@
   Tapestry 4.1. It offers an awful lot,  and is based around the functionality now familiar to many
   in {{{http://dojotoolkit.org}dojo}}'s {{{http://dojotoolkit.org/book/dojo-book-0-4/part-5-connecting-pieces/event-system-0}event API}}.
   
-  <<See also:>> {{{../tapestry-annotations/index.html#EventListener}EventListener}} core annotation documentation.,  {{{http://www.quirksmode.org/js/introevents.html}Quircksmode}}
+  <<See also:>> {{{../tapestry-annotations/index.html#EventListener}EventListener}} core annotation documentation.,  {{{http://www.quirksmode.org/js/introevents.html}Quirksmode}}
   
   At its core this new annotation allows you to bind client side events to page/component 
   {{{../usersguide/listenermethods.html}listener}} methods. "Client Side" events can have a lot

Modified: tapestry/tapestry4/trunk/src/site/apt/ajax/responsebuilder.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/src/site/apt/ajax/responsebuilder.apt?rev=613500&r1=613499&r2=613500&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/src/site/apt/ajax/responsebuilder.apt (original)
+++ tapestry/tapestry4/trunk/src/site/apt/ajax/responsebuilder.apt Sat Jan 19 18:46:31 2008
@@ -54,5 +54,41 @@
   
   Tapestry will correctly manage and render all javascript/form state/etc needed, depending on the component 
   type you are requesting an update on. 
+
+* Using ResponseBuilder for sending status messages and triggering client-side code
+
+  It is possible to trigger existing client-side code from a java listener method. This
+  is  made possible by {{{../apidocs/org/apache/tapestry/services/ResponseBuilder.html}ResponseBuilder}}s 
+  addStatusMessage method.
+
++-----------------------------------------------------------------------
+....
+
+@EventListener(targets = "projectChoose", events = "onValueChanged")
+public void projectSelected(IRequestCycle cycle)
+{
+  cycle.getResponseBuilder().updateComponent("myComponentId");
+  cycle.getResponseBuilder().addStatusMessage(null, "info", "A project was selected");
+}
+
+....
++-----------------------------------------------------------------------
   
- 
+  When the client is sent the ajax response, tapestry's javascript will 'publish' 
+  the status message at the specified topis, i.e. it will execute
+  dojo.event.topic.publish('info','A project was selected') 
+
+  You can take advantage of this behavior in several different ways:
+
+  [[1]] <<existing widgets>> - Dojo's Toaster is an example of a widget that
+  is subscribed to the 'info' topic. Whenever a message is published  there, it'll
+  scroll itself into view and display it.
+
+  [[1]] <<create new widgets>> - And making them behave like Toaster.
+
+  [[1]] <<trigger javascript code>> - it's easy to triggger your code whenever
+  a message is published. Here's some javascript that will alert the message:
+
++-----------------------------------------------------------------------
+dojo.event.topic.subscribe('info', function(msg) { alert(msg); });
++-----------------------------------------------------------------------