Author: hlship
Date: Sun Jun 24 08:30:37 2007
New Revision: 550250
URL: http://svn.apache.org/viewvc?view=rev&rev=550250
Log:
TAPESTRY-1583: The "block:" binding prefix may only reference blocks that
appear before the reference in the template, an error occurs if the block is
defined later in the template
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBinding.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBindingFactory.java
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/BlockDemo.html
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBinding.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBinding.java?view=auto&rev=550250
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBinding.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBinding.java
Sun Jun 24 08:30:37 2007
@@ -0,0 +1,48 @@
+// Copyright 2007 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.tapestry.internal.bindings;
+
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.ioc.Location;
+
+public class BlockBinding extends AbstractBinding
+{
+ private final String _description;
+
+ private final ComponentResources _component;
+
+ private final String _blockId;
+
+ public BlockBinding(final String description, final ComponentResources
component,
+ final String blockId, Location location)
+ {
+ super(location);
+
+ _description = description;
+ _component = component;
+ _blockId = blockId;
+ }
+
+ public Object get()
+ {
+ return _component.getBlock(_blockId);
+ }
+
+ @Override
+ public String toString()
+ {
+ return String.format("BlockBinding[%s: %s]", _description, _blockId);
+ }
+}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBindingFactory.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBindingFactory.java?view=diff&rev=550250&r1=550249&r2=550250
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBindingFactory.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/bindings/BlockBindingFactory.java
Sun Jun 24 08:30:37 2007
@@ -15,7 +15,6 @@
package org.apache.tapestry.internal.bindings;
import org.apache.tapestry.Binding;
-import org.apache.tapestry.Block;
import org.apache.tapestry.ComponentResources;
import org.apache.tapestry.ioc.Location;
import org.apache.tapestry.services.BindingFactory;
@@ -26,9 +25,7 @@
public Binding newBinding(String description, ComponentResources container,
ComponentResources component, String expression, Location location)
{
- Block block = container.getBlock(expression);
-
- return new LiteralBinding(description, block, location);
+ return new BlockBinding(description, container, expression, location);
}
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/BlockDemo.html
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/BlockDemo.html?view=diff&rev=550250&r1=550249&r2=550250
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/BlockDemo.html
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/WEB-INF/BlockDemo.html
Sun Jun 24 08:30:37 2007
@@ -15,4 +15,10 @@
<t:block id="fred">Block fred.</t:block>
<t:block id="barney">Block barney.</t:block>
+<hr/>
+
+ You can also render a block before it is defined: [<t:delegate
to="block:wilma"/>].
+
+ <t:block id="wilma">Block wilma</t:block>
+
</html>
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=550250&r1=550249&r2=550250
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
Sun Jun 24 08:30:37 2007
@@ -102,7 +102,10 @@
waitForPageToLoad(PAGE_LOAD_TIMEOUT);
assertTextPresent("[Block barney.]");
-
+
+ // TAPESETRY-1583
+
+ assertTextPresent("before it is defined: [Block wilma].");
}
@Test