You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/02/29 01:58:44 UTC

svn commit: r632188 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/corelib/components/ main/java/org/apache/tapestry/internal/services/ main/java/org/apache/tapestry/services/ main/resources/org/apache/tapestry/corelib/...

Author: hlship
Date: Thu Feb 28 16:58:43 2008
New Revision: 632188

URL: http://svn.apache.org/viewvc?rev=632188&view=rev
Log:
TAPESTRY-2200: Need a mechanism via which display and/or edit BeanBlocks may be overridden

Added:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockOverrideSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockOverrideSource.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/app3/BeanDisplayOverrideDemo.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/app3/PropertyDisplayBlockOverrides.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/BeanDisplayOverrideDemo.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/PropertyDisplayBlockOverrides.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/services/
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/services/AppModule.java
Removed:
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/NewIntegrationTests.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockSource.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RootPathRedirectTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanBlockSourceImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java?rev=632188&r1=632187&r2=632188&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/BeanDisplay.java Thu Feb 28 16:58:43 2008
@@ -45,6 +45,13 @@
     private Object _object;
 
     /**
+     * If true, then <span> tags around each output property will be omitted. If false, then a span tag (to
+     * identify the id of each property as the CSS class attribute) will be included.
+     */
+    @Parameter(value = "false")
+    private boolean _lean;
+
+    /**
      * The model that identifies the parameters to be displayed, their order, and every other aspect. If not specified,
      * a default bean model will be created from the type of the object bound to the object parameter.
      */
@@ -135,6 +142,23 @@
     public ComponentResources getOverrides()
     {
         return _overrides;
+    }
+
+    public String getLabelClass()
+    {
+        return generateClassValue("t-beandisplay-label");
+    }
+
+    private String generateClassValue(String className)
+    {
+        if (_lean) return className;
+
+        return className + " " + getPropertyModel().getId();
+    }
+
+    public String getValueClass()
+    {
+        return generateClassValue("t-beandisplay-value");
     }
 
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockOverrideSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockOverrideSourceImpl.java?rev=632188&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockOverrideSourceImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockOverrideSourceImpl.java Thu Feb 28 16:58:43 2008
@@ -0,0 +1,71 @@
+// 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.tapestry.internal.services;
+
+import org.apache.tapestry.Block;
+import org.apache.tapestry.internal.structure.Page;
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
+import org.apache.tapestry.services.BeanBlockContribution;
+import org.apache.tapestry.services.BeanBlockOverrideSource;
+
+import java.util.Collection;
+import java.util.Map;
+
+public class BeanBlockOverrideSourceImpl implements BeanBlockOverrideSource
+{
+    private final RequestPageCache _pageCache;
+
+    private final Map<String, BeanBlockContribution> _display = newCaseInsensitiveMap();
+
+    private final Map<String, BeanBlockContribution> _edit = newCaseInsensitiveMap();
+
+    public BeanBlockOverrideSourceImpl(RequestPageCache pageCache,
+                                       Collection<BeanBlockContribution> configuration)
+    {
+        _pageCache = pageCache;
+
+        for (BeanBlockContribution contribution : configuration)
+        {
+            Map<String, BeanBlockContribution> map = contribution.isEdit() ? _edit : _display;
+
+            map.put(contribution.getDataType(), contribution);
+        }
+    }
+
+    public boolean hasDisplayBlock(String datatype)
+    {
+        return _display.containsKey(datatype);
+    }
+
+    public Block getDisplayBlock(String datatype)
+    {
+        return toBlock(_display.get(datatype));
+    }
+
+    private Block toBlock(BeanBlockContribution contribution)
+    {
+        if (contribution == null) return null;
+
+        Page page = _pageCache.get(contribution.getPageName());
+
+        return page.getRootElement().getBlock(contribution.getBlockId());
+    }
+
+    public Block getEditBlock(String datatype)
+    {
+        return toBlock(_edit.get(datatype));
+    }
+
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockSourceImpl.java?rev=632188&r1=632187&r2=632188&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/BeanBlockSourceImpl.java Thu Feb 28 16:58:43 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 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.
@@ -15,67 +15,57 @@
 package org.apache.tapestry.internal.services;
 
 import org.apache.tapestry.Block;
-import org.apache.tapestry.internal.structure.Page;
-import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newCaseInsensitiveMap;
 import org.apache.tapestry.services.BeanBlockContribution;
+import org.apache.tapestry.services.BeanBlockOverrideSource;
 import org.apache.tapestry.services.BeanBlockSource;
 
 import java.util.Collection;
-import java.util.Map;
 
 public class BeanBlockSourceImpl implements BeanBlockSource
 {
-    private final RequestPageCache _pageCache;
+    // This is checked before _masterSource
 
-    private final Map<String, BeanBlockContribution> _display = newCaseInsensitiveMap();
+    private final BeanBlockOverrideSource _overrideSource;
+
+    private final BeanBlockOverrideSource _masterSource;
 
-    private final Map<String, BeanBlockContribution> _edit = newCaseInsensitiveMap();
 
     public BeanBlockSourceImpl(RequestPageCache pageCache,
-                               Collection<BeanBlockContribution> configuration)
+                               BeanBlockOverrideSource overrideSource, Collection<BeanBlockContribution> configuration)
     {
-        _pageCache = pageCache;
-
-        for (BeanBlockContribution contribution : configuration)
-        {
-            Map<String, BeanBlockContribution> map = contribution.isEdit() ? _edit : _display;
-
-            // TODO: Check for conflicts?
-
-            map.put(contribution.getDataType(), contribution);
-        }
+        _overrideSource = overrideSource;
+        _masterSource = new BeanBlockOverrideSourceImpl(pageCache, configuration);
     }
 
     public boolean hasDisplayBlock(String datatype)
     {
-        return _display.containsKey(datatype);
+        return _overrideSource.hasDisplayBlock(datatype) || _masterSource.hasDisplayBlock(datatype);
     }
 
     public Block getDisplayBlock(String datatype)
     {
-        BeanBlockContribution contribution = _display.get(datatype);
-
-        if (contribution == null)
-            throw new RuntimeException(ServicesMessages.noDisplayForDataType(datatype));
+        Block result = _overrideSource.getDisplayBlock(datatype);
 
-        return toBlock(contribution);
-    }
+        if (result == null)
+            result = _masterSource.getDisplayBlock(datatype);
 
-    private Block toBlock(BeanBlockContribution contribution)
-    {
-        Page page = _pageCache.get(contribution.getPageName());
+        if (result == null)
+            throw new RuntimeException(ServicesMessages.noDisplayForDataType(datatype));
 
-        return page.getRootElement().getBlock(contribution.getBlockId());
+        return result;
     }
 
     public Block getEditBlock(String datatype)
     {
-        BeanBlockContribution contribution = _edit.get(datatype);
+        Block result = _overrideSource.getEditBlock(datatype);
+
+        if (result == null)
+            result = _masterSource.getEditBlock(datatype);
 
-        if (contribution == null)
+        if (result == null)
             throw new RuntimeException(ServicesMessages.noEditForDataType(datatype));
 
-        return toBlock(contribution);
+        return result;
     }
 
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockOverrideSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockOverrideSource.java?rev=632188&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockOverrideSource.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockOverrideSource.java Thu Feb 28 16:58:43 2008
@@ -0,0 +1,52 @@
+// 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.tapestry.services;
+
+import org.apache.tapestry.Block;
+
+/**
+ * Used to override the default {@link org.apache.tapestry.services.BeanBlockSource} for a particular data type.  The
+ * service accepts the same configuration of {@link org.apache.tapestry.services.BeanBlockContribution}s as the main
+ * service.
+ */
+public interface BeanBlockOverrideSource
+{
+    /**
+     * Returns a block which can be used to render an editor for the given data type, in the form of a field label and
+     * input field.
+     *
+     * @param datatype logical name for the type of data to be displayed
+     * @return the Block
+     * @throws null if no override is available
+     */
+    Block getEditBlock(String datatype);
+
+    /**
+     * Returns a block which can be used to render output for the given data type.
+     *
+     * @param datatype logical name for the type of data to be displayed
+     * @return the Block
+     * @throws null if no override is available
+     */
+    Block getDisplayBlock(String datatype);
+
+    /**
+     * Checks to see if there is a display block for the indicated data type.
+     *
+     * @param datatype to check for
+     * @return true if an override display block is available
+     */
+    boolean hasDisplayBlock(String datatype);
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockSource.java?rev=632188&r1=632187&r2=632188&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockSource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/BeanBlockSource.java Thu Feb 28 16:58:43 2008
@@ -15,26 +15,27 @@
 package org.apache.tapestry.services;
 
 import org.apache.tapestry.Block;
-import org.apache.tapestry.corelib.components.BeanEditForm;
-import org.apache.tapestry.corelib.components.Grid;
 
 /**
- * A source of {@link Block}s used to display the properties of a bean (used by the {@link Grid}
- * component), or to edit the properties of a bean (used by the {@link BeanEditForm} component).
- * Contributions to this service define what properties may be editted.
+ * A source of {@link Block}s used to display the properties of a bean (used by the {@link
+ * org.apache.tapestry.corelib.components.Grid} component), or to edit the properties of a bean (used by the {@link
+ * org.apache.tapestry.corelib.components.BeanEditForm} component). Contributions to this service (a configuration of
+ * {@link BeanBlockContribution}s) define what properties may be editted.
  * <p/>
+ * Blocks are accessed in terms of a <strong>data type</strong> a string that identifies the type of data to be editted,
+ * such as "string", "date", "boolean", etc.
  * <p/>
- * Blocks are accessed in terms of a <strong>data type</strong> a string that identifies the type
- * of data to be editted, such as "string", "date", "boolean", etc.
+ * Tapestry contributes a number of default data types and corresponding edit and display blocks. The {@link
+ * org.apache.tapestry.services.BeanBlockOverrideSource} service allows these to be overridden.
  *
- * @see DataTypeAnalyzer
+ * @see org.apache.tapestry.services.DataTypeAnalyzer
  * @see org.apache.tapestry.services.TapestryModule#contributeBeanBlockSource(org.apache.tapestry.ioc.Configuration)
  */
 public interface BeanBlockSource
 {
     /**
-     * Returns a block which can be used to present an editor for the given data type, in the form
-     * of a field label and input field.
+     * Returns a block which can be used to render an editor for the given data type, in the form of a field label and
+     * input field.
      *
      * @param datatype logical name for the type of data to be displayed
      * @return the Block
@@ -43,7 +44,7 @@
     Block getEditBlock(String datatype);
 
     /**
-     * Returns a block which can be used to present an output for the given data type.
+     * Returns a block which can be used to render output for the given data type.
      *
      * @param datatype logical name for the type of data to be displayed
      * @return the Block

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=632188&r1=632187&r2=632188&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Thu Feb 28 16:58:43 2008
@@ -119,6 +119,7 @@
         binder.bind(ContextValueEncoder.class, ContextValueEncoderImpl.class);
         binder.bind(BaseURLSource.class, BaseURLSourceImpl.class);
         binder.bind(RequestSecurityManager.class, RequestSecurityManagerImpl.class);
+        binder.bind(BeanBlockOverrideSource.class, BeanBlockOverrideSourceImpl.class);
     }
 
     public static Alias build(Logger logger,

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml?rev=632188&r1=632187&r2=632188&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry/corelib/components/BeanDisplay.tml Thu Feb 28 16:58:43 2008
@@ -5,9 +5,9 @@
     <div class="t-beandisplay-row" t:type="loop" t:source="model.propertyNames"
          t:volatile="true" t:value="propertyName">
 
-        <div class="t-beandisplay-label">${propertyModel.label}:</div>
+        <div class="${labelClass}">${propertyModel.label}:</div>
 
-        <div class="t-beandisplay-value">
+        <div class="${valueClass}">
             <t:propertydisplay model="propertyModel" overrides="overrides" object="object"/>
         </div>
 

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app3/BeanDisplayOverrideDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app3/BeanDisplayOverrideDemo.tml?rev=632188&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app3/BeanDisplayOverrideDemo.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app3/BeanDisplayOverrideDemo.tml Thu Feb 28 16:58:43 2008
@@ -0,0 +1,11 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+    <head>
+        <title>BeanDisplay Global Override Demo</title>
+    </head>
+    <body>
+        <h1>BeanDisplay Global Override Demo</h1>
+
+        <t:beandisplay object="this"/>
+
+    </body>
+</html>
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml?rev=632188&r1=632187&r2=632188&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app3/Login.tml Thu Feb 28 16:58:43 2008
@@ -1,4 +1,4 @@
-<html>
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
     <head>
         <title>Login</title>
     </head>
@@ -8,5 +8,12 @@
         <p>
             You have reached this page via a redirect from the Index page's onActivate() event handler method.
         </p>
+
+        <ul>
+            <li>
+                 <t:pagelink page="beandisplayoverridedemo">BeanDisplay Override Demo</t:pagelink>
+            </li>
+        </ul>
+
     </body>
 </html>

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/app3/PropertyDisplayBlockOverrides.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app3/PropertyDisplayBlockOverrides.tml?rev=632188&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app3/PropertyDisplayBlockOverrides.tml (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app3/PropertyDisplayBlockOverrides.tml Thu Feb 28 16:58:43 2008
@@ -0,0 +1,11 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+    <t:block id="boolean">
+        <t:if test="context.propertyValue">
+            Yea
+            <t:parameter name="else">
+                Nay
+            </t:parameter>
+        </t:if>
+    </t:block>
+</html>
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RootPathRedirectTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RootPathRedirectTest.java?rev=632188&r1=632187&r2=632188&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RootPathRedirectTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RootPathRedirectTest.java Thu Feb 28 16:58:43 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 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.
@@ -17,7 +17,7 @@
 import org.apache.tapestry.test.AbstractIntegrationTestSuite;
 import org.testng.annotations.Test;
 
-@Test(timeOut = 50000, sequential = true, groups = {"integration"})
+@Test(timeOut = 50000, sequential = true, groups = { "integration" })
 public class RootPathRedirectTest extends AbstractIntegrationTestSuite
 {
 
@@ -38,5 +38,14 @@
         open(BASE_URL);
 
         assertText("//h1", "Login Page");
+    }
+
+    @Test
+    public void bean_block_overrides()
+    {
+        start("BeanDisplay Override Demo");
+
+        assertText("//div[@class='t-beandisplay-value no']", "Nay");
+        assertText("//div[@class='t-beandisplay-value yes']", "Yea");
     }
 }

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/BeanDisplayOverrideDemo.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/BeanDisplayOverrideDemo.java?rev=632188&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/BeanDisplayOverrideDemo.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/BeanDisplayOverrideDemo.java Thu Feb 28 16:58:43 2008
@@ -0,0 +1,29 @@
+// 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.tapestry.integration.app3.pages;
+
+public class BeanDisplayOverrideDemo
+{
+    public boolean getYes()
+    {
+        return true;
+    }
+
+    public boolean getNo()
+    {
+        return false;
+    }
+    
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/PropertyDisplayBlockOverrides.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/PropertyDisplayBlockOverrides.java?rev=632188&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/PropertyDisplayBlockOverrides.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/pages/PropertyDisplayBlockOverrides.java Thu Feb 28 16:58:43 2008
@@ -0,0 +1,29 @@
+// 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.tapestry.integration.app3.pages;
+
+import org.apache.tapestry.annotations.Environmental;
+import org.apache.tapestry.services.PropertyOutputContext;
+
+public class PropertyDisplayBlockOverrides
+{
+    @Environmental
+    private PropertyOutputContext _context;
+
+    public PropertyOutputContext getContext()
+    {
+        return _context;
+    }
+}

Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/services/AppModule.java?rev=632188&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/services/AppModule.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app3/services/AppModule.java Thu Feb 28 16:58:43 2008
@@ -0,0 +1,26 @@
+// 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.tapestry.integration.app3.services;
+
+import org.apache.tapestry.ioc.Configuration;
+import org.apache.tapestry.services.BeanBlockContribution;
+
+public class AppModule
+{
+    public void contributeBeanBlockOverrideSource(Configuration<BeanBlockContribution> configuration)
+    {
+        configuration.add(new BeanBlockContribution("checkbox", "PropertyDisplayBlockOverrides", "boolean", false));
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanBlockSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanBlockSourceImplTest.java?rev=632188&r1=632187&r2=632188&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanBlockSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanBlockSourceImplTest.java Thu Feb 28 16:58:43 2008
@@ -1,4 +1,4 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 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.
@@ -20,13 +20,17 @@
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
 import org.apache.tapestry.services.BeanBlockContribution;
+import org.apache.tapestry.services.BeanBlockOverrideSource;
 import org.apache.tapestry.services.BeanBlockSource;
 import org.testng.annotations.Test;
 
 import java.util.Collection;
+import java.util.Collections;
 
 public class BeanBlockSourceImplTest extends InternalBaseTestCase
 {
+    private static final Collection<BeanBlockContribution> EMPTY_CONFIGURATION = Collections.emptyList();
+
     @Test
     public void found_display_block()
     {
@@ -42,7 +46,7 @@
 
         replay();
 
-        BeanBlockSource source = new BeanBlockSourceImpl(cache, configuration);
+        BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
 
         // Check case insensitivity while we are at it.
         assertTrue(source.hasDisplayBlock("MyData"));
@@ -54,6 +58,40 @@
     }
 
     @Test
+    public void found_display_block_in_override()
+    {
+        Block block = mockBlock();
+        RequestPageCache cache = mockRequestPageCache();
+        BeanBlockOverrideSource overrideSource = mockBeanBlockOverrideSource();
+        String datatype = "MyData";
+
+        expect(overrideSource.hasDisplayBlock(datatype)).andReturn(true);
+        expect(overrideSource.getDisplayBlock(datatype)).andReturn(block);
+
+        replay();
+
+        BeanBlockSource source = new BeanBlockSourceImpl(cache, overrideSource, EMPTY_CONFIGURATION);
+
+        // Check case insensitivity while we are at it.
+        assertTrue(source.hasDisplayBlock(datatype));
+        Block actual = source.getDisplayBlock(datatype);
+
+        assertSame(actual, block);
+
+        verify();
+    }
+
+    protected final BeanBlockOverrideSource mockBeanBlockOverrideSource()
+    {
+        return newMock(BeanBlockOverrideSource.class);
+    }
+
+    private BeanBlockOverrideSource createBeanBlockOverrideSource(RequestPageCache cache)
+    {
+        return new BeanBlockOverrideSourceImpl(cache, EMPTY_CONFIGURATION);
+    }
+
+    @Test
     public void display_block_not_found()
     {
         RequestPageCache cache = mockRequestPageCache();
@@ -61,7 +99,7 @@
 
         replay();
 
-        BeanBlockSource source = new BeanBlockSourceImpl(cache, configuration);
+        BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
 
         try
         {
@@ -87,7 +125,7 @@
 
         replay();
 
-        BeanBlockSource source = new BeanBlockSourceImpl(cache, configuration);
+        BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
 
         try
         {
@@ -119,10 +157,31 @@
 
         replay();
 
-        BeanBlockSource source = new BeanBlockSourceImpl(cache, configuration);
+        BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);
 
         // Check case insensitivity while we are at it.
         Block actual = source.getEditBlock("MyData");
+
+        assertSame(actual, block);
+
+        verify();
+    }
+
+    @Test
+    public void found_edit_block_in_override()
+    {
+        Block block = mockBlock();
+        RequestPageCache cache = mockRequestPageCache();
+        BeanBlockOverrideSource overrideSource = mockBeanBlockOverrideSource();
+        String datatype = "MyData";
+
+        expect(overrideSource.getEditBlock(datatype)).andReturn(block);
+
+        replay();
+
+        BeanBlockSource source = new BeanBlockSourceImpl(cache, overrideSource, EMPTY_CONFIGURATION);
+
+        Block actual = source.getEditBlock(datatype);
 
         assertSame(actual, block);