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 2012/08/15 03:49:04 UTC

[1/2] git commit: Fix some broken logic when the partial page render response has a blank or null value for the content

Updated Branches:
  refs/heads/5.4-js-rewrite 2ae9d0aeb -> 168b13d8b


Fix some broken logic when the partial page render response has a blank or null value for the content


Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/168b13d8
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/168b13d8
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/168b13d8

Branch: refs/heads/5.4-js-rewrite
Commit: 168b13d8b02eab373a1ccf15edd4f549893e73f0
Parents: 6792fcf
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Tue Aug 14 18:48:44 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Tue Aug 14 18:48:44 2012 -0700

----------------------------------------------------------------------
 .../META-INF/modules/core/events.coffee            |    9 +++++----
 .../coffeescript/META-INF/modules/core/zone.coffee |   12 +++++++++---
 .../resources/org/apache/tapestry5/tapestry.js     |    9 ++++-----
 3 files changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/168b13d8/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee
index b754fc8..0edea76 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/events.coffee
@@ -50,10 +50,11 @@ define
   # to correctly support dynamic updates from the server via an Ajax request, and a standard response
   # (the partial page render reponse). More details are available in the `core/zone` module.
   zone:
-    # Invoked on a zone element to force an update to its content. The event memo is the new content (an Element, or a
-    # `core/spi:ElementWrapper`, or a string containing HTML markup). A standard top-level handler is defined by module
-    # `core/zone`, and is responsible for the actual update; it triggers the `events.zone.willUpdate` and
-    # `events.zone.didUpdate` events just before and just after changing the element's content.
+    # Invoked on a zone element to force an update to its content. The event memo should contain a `content` key (an
+    # Element, or a `core/spi:ElementWrapper`, or more typically, a string containing HTML markup). A standard top-level
+    # handler is defined by module `core/zone`, and is responsible for the actual update; it triggers the
+    # `events.zone.willUpdate` and `events.zone.didUpdate` events just before and just after changing the element's
+    # content.
     update: "t5:zone:update"
 
     # Triggered (by the standard handler) just before the content in a Zone will be updated.

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/168b13d8/tapestry-core/src/main/coffeescript/META-INF/modules/core/zone.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/core/zone.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/core/zone.coffee
index 7ed64c5..43f0d22 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/core/zone.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/core/zone.coffee
@@ -16,8 +16,8 @@
 #
 # Provides a default handler for the `events.zone.update` event, attached to the
 # document body.
-define ["core/spi", "core/events"],
-  (spi, events) ->
+define ["core/spi", "core/events", "_"],
+  (spi, events, _) ->
     spi.domReady ->
       spi.body().on events.zone.update, (event) ->
 
@@ -25,7 +25,13 @@ define ["core/spi", "core/events"],
 
         # TODO: purge existing children?
 
-        this.update event.memo
+        content = event.memo.content
+
+        # The server may have passed down the empty string for the content; that removes the existing content.
+        # On the other hand, the server may have not provided a content key; in that case, content is undefined
+        # which means to leave the existing content alone.
+        unless content is undefined
+          this.update content
 
         this.show() unless this.visible()
 

http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/168b13d8/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
index 743da36..1763351 100644
--- a/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
+++ b/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
@@ -1433,15 +1433,14 @@ define("core/compat/tapestry", [
         },
 
         /**
-         * Updates the zone's content, and invokes either the update function (to
-         * highlight the change) or the show function (to reveal a hidden element).
-         * Lastly, fires the Tapestry.ZONE_UPDATED_EVENT to let listeners know that
-         * the zone was updated.
+         * Updates the zone's content; as of 5.4 this is just a shell
+         * that triggers the events.zone.update event; see the core/zone module
+         * for the default handler for that event.
          *
          * @param content
          */
         show: function (content) {
-            this.element.trigger(events.zone.update, content);
+            this.element.trigger(events.zone.update, { content: content });
         },
 
         /**