You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2014/08/04 10:43:06 UTC
git commit: TAP5-2100: ZoneRefresh mixin triggers refresh event with
wrong context
Repository: tapestry-5
Updated Branches:
refs/heads/master 30a66c952 -> e087cad11
TAP5-2100: ZoneRefresh mixin triggers refresh event with wrong context
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/e087cad1
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/e087cad1
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/e087cad1
Branch: refs/heads/master
Commit: e087cad11d609bc251727be91bf3d523811d541d
Parents: 30a66c9
Author: Ivan Khalopik <ik...@gmail.com>
Authored: Thu Mar 28 19:40:14 2013 +0300
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Mon Aug 4 10:42:25 2014 +0200
----------------------------------------------------------------------
.../tapestry5/corelib/mixins/ZoneRefresh.java | 5 ++-
tapestry-core/src/test/app1/Index.tml | 4 ++
.../src/test/app1/ZoneRefreshWithContext.tml | 13 ++++++
.../integration/app1/ZoneRefreshTest.java | 21 ++++++++++
.../app1/pages/ZoneRefreshWithContext.java | 44 ++++++++++++++++++++
5 files changed, 85 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e087cad1/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/ZoneRefresh.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/ZoneRefresh.java b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/ZoneRefresh.java
index 130f7dc..d2ca6dd 100644
--- a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/ZoneRefresh.java
+++ b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/mixins/ZoneRefresh.java
@@ -17,6 +17,7 @@ package org.apache.tapestry5.corelib.mixins;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventConstants;
+import org.apache.tapestry5.EventContext;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.annotations.AfterRender;
import org.apache.tapestry5.annotations.Events;
@@ -83,10 +84,10 @@ public class ZoneRefresh
javaScriptSupport.require("t5/core/zone-refresh").with(zone.getClientId(), period, link.toString());
}
- Object onZoneRefresh()
+ Object onZoneRefresh(EventContext eventContext)
{
CaptureResultCallback<Object> callback = new CaptureResultCallback<Object>();
- resources.triggerEvent(EventConstants.REFRESH, context, callback);
+ resources.triggerContextEvent(EventConstants.REFRESH, eventContext, callback);
if (callback.getResult() != null)
{
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e087cad1/tapestry-core/src/test/app1/Index.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/Index.tml b/tapestry-core/src/test/app1/Index.tml
index d9a0252..1e7ca79 100644
--- a/tapestry-core/src/test/app1/Index.tml
+++ b/tapestry-core/src/test/app1/Index.tml
@@ -159,6 +159,10 @@
-- refreshes zone with an event handler returning zone
</li>
<li>
+ <a href="ZoneRefreshWithContext">Zone Refresh With Context</a>
+ -- refreshes zone with a context
+ </li>
+ <li>
<a href="UnsupportedParameterBlockDemo">Unsupported Parameter Block Demo</a>
-- informal block parameter to a component that does not support informal parameters
</li>
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e087cad1/tapestry-core/src/test/app1/ZoneRefreshWithContext.tml
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/app1/ZoneRefreshWithContext.tml b/tapestry-core/src/test/app1/ZoneRefreshWithContext.tml
new file mode 100644
index 0000000..956daab
--- /dev/null
+++ b/tapestry-core/src/test/app1/ZoneRefreshWithContext.tml
@@ -0,0 +1,13 @@
+<html xmlns:t='http://tapestry.apache.org/schema/tapestry_5_1_0.xsd'>
+ <head>
+ </head>
+
+ <body>
+ Using zone with context :
+ <span t:type='zone' t:mixins='zonerefresh' t:period='2' t:context='counter' id='zone' t:id='zone'>
+ ${changed}
+ </span>
+ <t:actionlink t:id='link' zone='zone'>Add</t:actionlink>
+ </body>
+
+</html>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e087cad1/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneRefreshTest.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneRefreshTest.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneRefreshTest.java
index c18890c..1178fb1 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneRefreshTest.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneRefreshTest.java
@@ -44,6 +44,27 @@ public class ZoneRefreshTest extends App1TestCase
checkZoneValues("zone", 3);
}
+ @Test
+ public void test_if_zone_with_context_works() throws Exception
+ {
+ openBaseURL();
+ clickAndWait("link=Zone Refresh With Context");
+
+ // assert that counter value didn't changed
+ assertText("zone", "false");
+ Thread.sleep(2000l);
+ assertText("zone", "false");
+
+ // increment counter
+ click("link=Add");
+ waitForAjaxRequestsToComplete();
+
+ // assert that counter value didn't changed
+ assertText("zone", "true");
+ Thread.sleep(2000l);
+ assertText("zone", "true");
+ }
+
private void checkZoneValues(String zone, int times) throws Exception
{
// Wait until Prototype is loaded ...
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/e087cad1/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ZoneRefreshWithContext.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ZoneRefreshWithContext.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ZoneRefreshWithContext.java
new file mode 100644
index 0000000..2af2885
--- /dev/null
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/ZoneRefreshWithContext.java
@@ -0,0 +1,44 @@
+// Copyright 2011 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.annotations.Persist;
+import org.apache.tapestry5.annotations.Property;
+
+public class ZoneRefreshWithContext
+{
+ @Persist
+ @Property
+ private int counter;
+
+ @Persist
+ @Property
+ private boolean changed;
+
+ void setupRender()
+ {
+ counter = 0;
+ }
+
+ void onRefreshFromZone(int counter)
+ {
+ this.changed = this.counter != counter;
+ }
+
+ void onActionFromLink()
+ {
+ this.counter++;
+ }
+}
+