You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2010/03/19 03:04:13 UTC

svn commit: r925077 - /tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Zone.java

Author: hlship
Date: Fri Mar 19 02:04:12 2010
New Revision: 925077

URL: http://svn.apache.org/viewvc?rev=925077&view=rev
Log:
TAP5-1061: When a Zone component sends an Ajax request for a client-side update, it should pass an extra query parameter identifying the zone's client-side id

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Zone.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Zone.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Zone.java?rev=925077&r1=925076&r2=925077&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Zone.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Zone.java Fri Mar 19 02:04:12 2010
@@ -1,10 +1,10 @@
-// Copyright 2007, 2008, 2009 The Apache Software Foundation
+// Copyright 2007, 2008, 2009, 2010 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
-//     http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
@@ -23,9 +23,8 @@ import org.apache.tapestry5.ioc.annotati
 import org.apache.tapestry5.json.JSONObject;
 import org.apache.tapestry5.services.ClientBehaviorSupport;
 
-
 /**
- * A Zone is portion of the output page designed for easy dynamic updating via Ajax or other client-side effects.  A
+ * A Zone is portion of the output page designed for easy dynamic updating via Ajax or other client-side effects. A
  * Zone renders out as a <div> element (or whatever is specified in the template) and may have content initially,
  * or may only get its content as a result of client side activity.
  * <p/>
@@ -34,8 +33,8 @@ import org.apache.tapestry5.services.Cli
  * When a user clicks an {@link org.apache.tapestry5.corelib.components.ActionLink} whose zone parameter is set, the
  * corresponding client-side Tapestry.ZoneManager object is located. It will update the content of the Zone's
  * &lt;div&gt; and then invoke either a show method (if the div is not visible) or an update method (if the div is
- * visible).  The show and update parameters are the <em>names</em> of functions attached to the Tapestry.ElementEffect
- * object.    Likewise, a {@link org.apache.tapestry5.corelib.components.Form} component may also trigger an update of a
+ * visible). The show and update parameters are the <em>names</em> of functions attached to the Tapestry.ElementEffect
+ * object. Likewise, a {@link org.apache.tapestry5.corelib.components.Form} component may also trigger an update of a
  * client-side Zone.
  * <p/>
  * The server side event handler can return a {@link org.apache.tapestry5.Block} or a component to render as the new
@@ -46,11 +45,17 @@ import org.apache.tapestry5.services.Cli
  * <p/>
  * You will often want to specify the id parameter of the Zone, in addition to it's Tapestry component id; this "locks
  * down" the client-side id, so the same value is used even in later partial renders of the page (essential if the Zone
- * is nested inside another Zone).  When you specify the client-side id, it is used exactly as provided (meaning that
- * you are responsible for ensuring that there will not be an id conflict even in the face of multiple partial renders
- * of the page). Failure to provide an explicit id results in a new, and non-predictable, id being generated for each
+ * is nested inside another Zone). When you specify the client-side id, it is used exactly as provided (meaning that you
+ * are responsible for ensuring that there will not be an id conflict even in the face of multiple partial renders of
+ * the page). Failure to provide an explicit id results in a new, and non-predictable, id being generated for each
  * partial render, which will often result in client-side failures to locate the element to update when the Zone is
  * triggered.
+ * <p>
+ * In some cases, you may want to know (on the server side) the client id of the zone that was updated; this is passed
+ * as part of the Ajax request, as the {@link QueryParameterConstants#ZONE_ID} parameter. An example use of this would
+ * be to provide new content into a Zone that updates the same Zone, when the Zone's client-side id is dynamically
+ * allocated (rather than statically defined). In most cases, however, the programmer is responsible for assigning a
+ * specific client-side id, via the id parameter.
  * <p/>
  * After the client-side content is updated, a client-side event is fired on the zone's element. The constant
  * Tapestry.ZONE_UPDATED_EVENT can be used to listen to the event.
@@ -60,7 +65,7 @@ public class Zone implements ClientEleme
 {
     /**
      * Name of a function on the client-side Tapestry.ElementEffect object that is invoked to make the Zone's
-     * &lt;div&gt; visible before being updated.  If not specified, then the basic "show" method is used.
+     * &lt;div&gt; visible before being updated. If not specified, then the basic "show" method is used.
      */
     @Parameter(defaultPrefix = BindingConstants.LITERAL)
     private String show;
@@ -94,7 +99,7 @@ public class Zone implements ClientEleme
     private ClientBehaviorSupport clientBehaviorSupport;
 
     /**
-     * If true (the default) then the zone will render normally.  If false, then the "t-invisible" CSS class is added,
+     * If true (the default) then the zone will render normally. If false, then the "t-invisible" CSS class is added,
      * which will make the zone initially invisible.
      */
     @Parameter
@@ -120,7 +125,8 @@ public class Zone implements ClientEleme
 
         e.addClassName("t-zone");
 
-        if (!visible) e.addClassName(CSSClassConstants.INVISIBLE);
+        if (!visible)
+            e.addClassName(CSSClassConstants.INVISIBLE);
 
         // And continue on to render the body
 
@@ -138,7 +144,7 @@ public class Zone implements ClientEleme
     /**
      * The client id of the Zone; this is set when the Zone renders and will either be the value bound to the id
      * parameter, or an allocated unique id.
-     *
+     * 
      * @return client-side element id
      */
     public String getClientId()
@@ -149,7 +155,7 @@ public class Zone implements ClientEleme
     /**
      * Returns the zone's body (the content enclosed by its start and end tags). This is often used as part of an Ajax
      * partial page render to update the client with a fresh render of the content inside the zone.
-     *
+     * 
      * @return the zone's body as a Block
      */
     public Block getBody()