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 2008/08/06 01:11:21 UTC
svn commit: r683027 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry5/
main/java/org/apache/tapestry5/internal/structure/ test/app1/
test/java/org/apache/tapestry5/integration/
test/java/org/apache/tapestry5/integration/a...
Author: hlship
Date: Tue Aug 5 16:11:20 2008
New Revision: 683027
URL: http://svn.apache.org/viewvc?rev=683027&view=rev
Log:
TAPESTRY-2542: Add new method hasBody() to ComponentResources, to reveal if component has a body or not
Added:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/HasBodyDemo.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/HasBodyDemo.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResourcesCommon.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResourcesCommon.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResourcesCommon.java?rev=683027&r1=683026&r2=683027&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResourcesCommon.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/ComponentResourcesCommon.java Tue Aug 5 16:11:20 2008
@@ -142,4 +142,11 @@
* @return the logical name of the page which contains this component
*/
String getPageName();
+
+
+ /**
+ * Returns true if the element has a body and false otherwise. Only components may have a body; pages and mixins
+ * will return false.
+ */
+ boolean hasBody();
}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java?rev=683027&r1=683026&r2=683027&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/ComponentPageElementImpl.java Tue Aug 5 16:11:20 2008
@@ -943,8 +943,11 @@
queue.startComponent(coreResources);
+ // POP_COMPONENT_ID will remove the component we just started.
+
queue.push(POP_COMPONENT_ID);
+ // This is the start of the real state machine for the component.
queue.push(setupRender);
}
@@ -1173,6 +1176,11 @@
return page.getLogicalName();
}
+ public boolean hasBody()
+ {
+ return body != null;
+ }
+
public Map<String, Binding> getInformalParameterBindings()
{
return coreResources.getInformalParameterBindings();
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java?rev=683027&r1=683026&r2=683027&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/structure/InternalComponentResourcesImpl.java Tue Aug 5 16:11:20 2008
@@ -144,6 +144,11 @@
return getElementName(null);
}
+ public boolean hasBody()
+ {
+ return element.hasBody();
+ }
+
public String getCompleteId()
{
return completeId;
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/HasBodyDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/HasBodyDemo.tml?rev=683027&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/HasBodyDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/HasBodyDemo.tml Tue Aug 5 16:11:20 2008
@@ -0,0 +1,17 @@
+<html t:type="border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+ <h1>Has Body Demo</h1>
+
+ <p>
+ <span t:type="any" t:id="nobody"/>
+
+ <span t:type="any" t:id="somebody">Body inside component 'somebody'.</span>
+ </p>
+
+ <dl>
+ <dt>Component nobody</dt>
+ <dd id="nobody">${nobody.componentResources.hasBody()}</dd>
+ <dt>Component somebody</dt>
+ <dd id="somebody">${somebody.componentResources.hasBody()}</dd>
+ </dl>
+</html>
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java?rev=683027&r1=683026&r2=683027&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/IntegrationTests.java Tue Aug 5 16:11:20 2008
@@ -2122,4 +2122,15 @@
assertEquals(count, "7", "Expected seven rows: the header and six data rows.");
}
+
+ /**
+ * TAPESTRY-2542
+ */
+ public void has_body()
+ {
+ start("Has Body Demo");
+
+ assertText("nobody", "false");
+ assertText("somebody", "true");
+ }
}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/HasBodyDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/HasBodyDemo.java?rev=683027&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/HasBodyDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/HasBodyDemo.java Tue Aug 5 16:11:20 2008
@@ -0,0 +1,31 @@
+// Copyright 2008 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.InjectComponent;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.runtime.Component;
+
+public class HasBodyDemo
+{
+
+ @InjectComponent
+ @Property
+ private Component nobody;
+
+ @InjectComponent
+ @Property
+ private Component somebody;
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java?rev=683027&r1=683026&r2=683027&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/pages/Start.java Tue Aug 5 16:11:20 2008
@@ -270,7 +270,9 @@
new Item("inplacegriddemo", "In-Place Grid Demo", "Grid that updates in-place using Ajax"),
- new Item("methodadvicedemo", "Method Advice Demo", "Advising component methods.")
+ new Item("methodadvicedemo", "Method Advice Demo", "Advising component methods."),
+
+ new Item("HasBodyDemo", "Has Body Demo", "Verify the hasBody() method of ComponentResources")
);
static