You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jo...@apache.org on 2011/06/15 07:23:23 UTC
svn commit: r1135921 - in /tapestry/tapestry5/trunk/tapestry-core/src/test:
java/org/apache/tapestry5/integration/app1/
java/org/apache/tapestry5/integration/app1/pages/
resources/org/apache/tapestry5/integration/app1/pages/
Author: joshcanfield
Date: Wed Jun 15 05:23:23 2011
New Revision: 1135921
URL: http://svn.apache.org/viewvc?rev=1135921&view=rev
Log:
TAP5-1413 - added unit test to cover multi-zone update with a String as the zone body.
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java?rev=1135921&r1=1135920&r2=1135921&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/ZoneTests.java Wed Jun 15 05:23:23 2011
@@ -261,4 +261,38 @@ public class ZoneTests extends TapestryC
select("//div[@id='select2ValueZone']//select", "4 post ajax");
}
+ @Test
+ public void multi_zone_update_using_string_in_loop() {
+ openLinks("MultiZone String Body Demo");
+ String[] numbers = new String[]{
+ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"
+ };
+
+ for (int i = 0; i <= 10; i++) {
+ assertText("row-" + i, numbers[i]);
+ }
+
+ click("click_7");
+ waitForElementToAppear("row-7");
+
+ // 7- are unchanged
+ for (int i = 0; i <= 7; i++) {
+ assertText("row-" + i, numbers[i]);
+ }
+ // 8+ are modified
+ for (int i = 8; i <= 10; i++) {
+ assertText("row-" + i, i + " is the integer value");
+ }
+
+ click("reset");
+ waitForElementToAppear("wholeLoopZone");
+
+ // all elements reset via AJAX
+ for (int i = 0, numbersLength = numbers.length; i < numbersLength; i++) {
+ assertText("row-" + i, numbers[i]);
+ }
+
+ }
+
+
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java?rev=1135921&r1=1135920&r2=1135921&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Index.java Wed Jun 15 05:23:23 2011
@@ -85,6 +85,9 @@ public class Index
new Item("ZoneFormUpdateDemo", "Zone/Form Update Demo", "Updating a Zone inside a Form"),
+ new Item("MultiZoneStringBodyDemo", "MultiZone String Body Demo",
+ "Multi-zone updates in a loop using strings coerced into blocks"),
+
new Item("RenderNotificationDemo", "RenderNotification Demo", "Use of RenderNotification mixin"),
new Item("InjectMessagesDemo", "Inject Global Messages into Service Demo",
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java?rev=1135921&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.java Wed Jun 15 05:23:23 2011
@@ -0,0 +1,63 @@
+package org.apache.tapestry5.integration.app1.pages;
+
+import org.apache.tapestry5.Block;
+import org.apache.tapestry5.ajax.MultiZoneUpdate;
+import org.apache.tapestry5.annotations.InjectComponent;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.corelib.components.Zone;
+
+public class MultiZoneStringBodyDemo {
+
+ @Property
+ private String[] list = {
+ "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"
+ };
+
+ @Property
+ private int index;
+
+ @Property
+ private String item;
+
+ @InjectComponent
+ private Zone wholeLoopZone;
+
+ @InjectComponent
+ private Zone dummyZone;
+
+ public String getRowId() {
+ return "row-" + index;
+ }
+
+ public String getClickId() {
+ return "click_" + getItemId();
+ }
+
+ public int getItemId() {
+ return index;
+ }
+
+ public MultiZoneUpdate onClick(int i) {
+
+ MultiZoneUpdate mzu = new MultiZoneUpdate("dummyZone", dummyZone);
+
+ while (i < list.length) {
+
+ String clientId = "row-" + (i);
+
+ String value = Integer.toString(i) + " is the integer value";
+
+ mzu = mzu.add(clientId, value);
+
+ ++i;
+ }
+
+ return mzu;
+
+ }
+
+ public Block onReset() {
+ return wholeLoopZone.getBody();
+ }
+
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml?rev=1135921&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/MultiZoneStringBodyDemo.tml Wed Jun 15 05:23:23 2011
@@ -0,0 +1,23 @@
+<html t:type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xml:space="default">
+
+<h1>Zone/Ajax Loop/MultiZoneUpdate</h1>
+
+A multi-zone update that is determined dynamically and uses a string that is coerced into a block to update a zone.
+
+<t:zone t:id="wholeLoopZone" id="wholeLoopZone">
+
+ <ul t:type="loop" t:source="list" t:value="item" index="index">
+ <li>
+ <t:eventlink t:id="click" t:event="click" t:zone="wholeLoopZone" t:context="itemId">click</t:eventlink>
+
+ <span t:type="zone" t:id="numberZone" id="${rowId}">${item}</span>
+ </li>
+ </ul>
+
+</t:zone>
+
+<t:eventlink t:id="reset" t:event="reset" t:zone="wholeLoopZone">reset</t:eventlink>
+
+<t:zone t:id="dummyZone" id="dummyZone"/>
+
+</html>