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/11/05 21:41:05 UTC
svn commit: r1031783 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/ main/java/org/apache/tapestry5/ajax/
main/java/org/apache/tapestry5/corelib/components/ test/app1/
test/java/org/apache/tapestry5/integration/app1/ t...
Author: hlship
Date: Fri Nov 5 20:41:04 2010
New Revision: 1031783
URL: http://svn.apache.org/viewvc?rev=1031783&view=rev
Log:
TAP5-1333: Zone should implement an interface, BodyElement, that extends ClientElement and provides the body property
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientBodyElement.java (with props)
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientElement.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ajax/MultiZoneUpdate.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Zone.java
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MultiZoneUpdateDemo.tml
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/MultiZoneUpdateDemo.java
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientBodyElement.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientBodyElement.java?rev=1031783&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientBodyElement.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientBodyElement.java Fri Nov 5 20:41:04 2010
@@ -0,0 +1,30 @@
+// Copyright 2010 [ORG]
+//
+// 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;
+
+import org.apache.tapestry5.ajax.MultiZoneUpdate;
+
+/**
+ * Extends {@link ClientElement} with the concept of a body, a Block that can be rendered to provide the content
+ * within. The primary implementation of this is the {@link Zone} component, which exposes its client id and body for
+ * use with {@link MultiZoneUpdate}.
+ *
+ * @since 5.2.3
+ * @see MultiZoneUpdate#add(ClientBodyElement)
+ */
+public interface ClientBodyElement extends ClientElement
+{
+ Block getBody();
+}
Propchange: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientBodyElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientElement.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientElement.java?rev=1031783&r1=1031782&r2=1031783&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientElement.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ClientElement.java Fri Nov 5 20:41:04 2010
@@ -19,7 +19,7 @@ import org.apache.tapestry5.services.jav
/**
* Interface for any kind of object (typically, a component) that can provide a {@linkplain #getClientId() client-side
* id}, typically used in the generation of client-side (JavaScript) logic. For components, the client id will be null
- * or innaccurate until after the component has rendered itself. Inside of any kind of loop, the clientId property is
+ * or inaccurate until after the component has rendered itself. Inside of any kind of loop, the clientId property is
* only accurate just after the component has rendered, and before it renders again.
* <p/>
* Some components must be configured to provide a client id. In many cases, the client id matches the component's
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ajax/MultiZoneUpdate.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ajax/MultiZoneUpdate.java?rev=1031783&r1=1031782&r2=1031783&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ajax/MultiZoneUpdate.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ajax/MultiZoneUpdate.java Fri Nov 5 20:41:04 2010
@@ -16,6 +16,7 @@ package org.apache.tapestry5.ajax;
import java.util.Map;
+import org.apache.tapestry5.ClientBodyElement;
import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
import org.apache.tapestry5.ioc.internal.util.InternalUtils;
@@ -55,6 +56,18 @@ public class MultiZoneUpdate
}
/**
+ * Adds the zone (represented by the {@link ClientBodyElement}) to the update.
+ *
+ * @since 5.2.3
+ */
+ public MultiZoneUpdate add(ClientBodyElement zone)
+ {
+ assert zone != null;
+
+ return add(zone.getClientId(), zone.getBody());
+ }
+
+ /**
* Returns a <strong>new</strong> MultiZoneUpdate reflecting the mapping from the indicated zone to an object that
* will render the content for that zone.
*
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=1031783&r1=1031782&r2=1031783&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 Nov 5 20:41:04 2010
@@ -17,7 +17,7 @@ package org.apache.tapestry5.corelib.com
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.CSSClassConstants;
-import org.apache.tapestry5.ClientElement;
+import org.apache.tapestry5.ClientBodyElement;
import org.apache.tapestry5.ComponentAction;
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.MarkupWriter;
@@ -80,7 +80,7 @@ import org.slf4j.Logger;
* Tapestry.ZONE_UPDATED_EVENT can be used to listen to the event.
*/
@SupportsInformalParameters
-public class Zone implements ClientElement
+public class Zone implements ClientBodyElement
{
/**
* Name of a function on the client-side Tapestry.ElementEffect object that is invoked to make the Zone's
@@ -231,7 +231,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. When the id parameter is bound, this value is always accurate.
* When the id parameter is not bound, the clientId is set during the {@linkplain BeginRender begin render phase}
- * and will be null or innacurate before then.
+ * and will be null or inaccurate before then.
*
* @return client-side element id
*/
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MultiZoneUpdateDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MultiZoneUpdateDemo.tml?rev=1031783&r1=1031782&r2=1031783&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MultiZoneUpdateDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/MultiZoneUpdateDemo.tml Fri Nov 5 20:41:04 2010
@@ -1,51 +1,54 @@
-<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
- xmlns:p="tapestry:parameter">
+<t:border xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" xmlns:p="tapestry:parameter">
- <h1>Multi-Zone Update Demo</h1>
+ <h1>Multi-Zone Update Demo</h1>
- <span id="now">${now}</span>
+ <span id="now">${now}</span>
- <div class="t-data-grid" style="{width: 100%;}">
+ <div class="t-data-grid" style="{width: 100%;}">
- <table class="t-data-grid">
- <thead>
+ <table class="t-data-grid">
+ <thead>
- <tr>
- <th>Fred</th>
- <th>Barney</th>
- <th>Dino</th>
- </tr>
- </thead>
- <tbody>
+ <tr>
+ <th>Fred</th>
+ <th>Barney</th>
+ <th>Dino</th>
+ <th>Wilma</th>
+ </tr>
+ </thead>
+ <tbody>
- <tr>
- <td t:type="zone" t:id="fredZone" id="fred">
- Placeholder
+ <tr>
+ <td t:type="zone" t:id="fredZone" id="fred">
+ Placeholder
</td>
- <td t:type="zone" t:id="barneyZone" id="barney">
- Placeholder
+ <td t:type="zone" t:id="barneyZone" id="barney">
+ Placeholder
</td>
- <td t:type="zone" t:id="dinoZone" id="dino">
- Placeholder
+ <td t:type="zone" t:id="dinoZone" id="dino">
+ Placeholder
</td>
- </tr>
- </tbody>
- </table>
- </div>
-
- <t:actionlink t:id="update" zone="fred">update</t:actionlink>
-
- <t:block id="fredBlock">
- <span id="fredName">Fred Flintstone</span>
- </t:block>
-
- <t:block id="barneyBlock">
- <t:form>
- <t:palette t:id="options" model="options" encoder="encoder"/>
- <input type="submit"/>
+ <td t:type="zone" t:id="wilmaZone" id="wilma">
+ ${wilmaMessage}
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+
+ <t:actionlink t:id="update" zone="fred">update</t:actionlink>
+
+ <t:block id="fredBlock">
+ <span id="fredName">Fred Flintstone</span>
+ </t:block>
+
+ <t:block id="barneyBlock">
+ <t:form>
+ <t:palette t:id="options" model="options" encoder="encoder"/>
+ <input type="submit"/>
- </t:form>
- </t:block>
+ </t:form>
+ </t:block>
</t:border>
\ No newline at end of file
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=1031783&r1=1031782&r2=1031783&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 Fri Nov 5 20:41:04 2010
@@ -110,12 +110,15 @@ public class ZoneTests extends TapestryC
String now = getText("now");
+ assertText("wilma", "Wilma Flintstone");
+
click("update");
waitForElementToAppear("fredName");
assertText("fredName", "Fred Flintstone");
assertText("dino", "His dog, Dino.");
+ assertText("wilma", "His Wife, Wilma.");
// Ideally, we'd add checks that the JavaScript for the Palette in the
// Barney Zone was
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneUpdateDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneUpdateDemo.java?rev=1031783&r1=1031782&r2=1031783&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneUpdateDemo.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/MultiZoneUpdateDemo.java Fri Nov 5 20:41:04 2010
@@ -1,10 +1,10 @@
-// Copyright 2009 The Apache Software Foundation
+// Copyright 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,
@@ -14,19 +14,28 @@
package org.apache.tapestry5.integration.app1.pages;
+import java.util.Date;
+
import org.apache.tapestry5.Block;
import org.apache.tapestry5.ValueEncoder;
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;
import org.apache.tapestry5.internal.services.StringValueEncoder;
import org.apache.tapestry5.ioc.annotations.Inject;
-import java.util.Date;
-
public class MultiZoneUpdateDemo
{
@Inject
private Block fredBlock, barneyBlock;
+ @Property
+ private String wilmaMessage = "Wilma Flintstone";
+
+ @InjectComponent
+ private Zone wilmaZone;
+
public Date getNow()
{
return new Date();
@@ -34,12 +43,16 @@ public class MultiZoneUpdateDemo
Object onActionFromUpdate()
{
- return new MultiZoneUpdate("fred", fredBlock).add("barney", barneyBlock).add("dino", "His dog, Dino.");
+ wilmaMessage = "His Wife, Wilma.";
+
+ return new MultiZoneUpdate("fred", fredBlock).add("barney", barneyBlock).add("dino", "His dog, Dino.")
+ .add(wilmaZone);
}
public String[] getOptions()
{
- return new String[] { "Red", "Green", "Blue" };
+ return new String[]
+ { "Red", "Green", "Blue" };
}
public ValueEncoder getEncoder()