tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r509396 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/ main/java/org/apache/tapestry/corelib/base/ main/java/org/apache/tapestry/corelib/components/ main/java/org/apache/tapestry/dom/ main/java/org/apache/t...
Date Tue, 20 Feb 2007 00:48:36 GMT
Author: hlship
Date: Mon Feb 19 16:48:34 2007
New Revision: 509396

URL: http://svn.apache.org/viewvc?view=rev&rev=509396
Log:
Add DefaultComponentParameterBindingSource service, to simplify creating default bindings that relate a parameter to a property of the component's container.
Move a couple of constants from InternalConstants to TapestryConstants.
Add support for rendering raw (unfiltered, unescaped) text into the DOM.
Add a RawOutput component for rendering raw (unfiltered0.

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/OutputRaw.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Raw.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/DefaultComponentParameterBindingSource.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/corelib/components/OutputRawTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImplTest.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/MarkupWriter.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryConstants.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalConstants.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderProcessor.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ParameterWorkerTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/MarkupWriter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/MarkupWriter.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/MarkupWriter.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/MarkupWriter.java Mon Feb 19 16:48:34 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -19,6 +19,7 @@
 import org.apache.tapestry.dom.Document;
 import org.apache.tapestry.dom.Element;
 import org.apache.tapestry.dom.MarkupModel;
+import org.apache.tapestry.dom.Raw;
 
 /**
  * An interface used by objects, such as Tapestry components, that need to render themselves as some
@@ -66,6 +67,16 @@
 
     /** Writes a formatted string. */
     void writef(String format, Object... args);
+
+    /**
+     * Writes <em>raw</em> text, text with existing markup that should be passed through the
+     * client without change. This can be useful when the markup is read from an external source (a
+     * file or a database) and is simply to be included.
+     * 
+     * @param text
+     * @see Raw
+     */
+    void writeRaw(String text);
 
     /**
      * Adds an XML comment. The text should be just the comment content, the comment delimiters will

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryConstants.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryConstants.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/TapestryConstants.java Mon Feb 19 16:48:34 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -39,6 +39,12 @@
      * Request path prefix that identifies an internal (on the classpath) asset.
      */
     public static final String ASSET_PATH_PREFIX = "/assets/";
+
+    /** Binding expression prefix used for literal strings. */
+    public static final String LITERAL_BINDING_PREFIX = "literal";
+
+    /** Binding expression prefix used to bind to a property of the component. */
+    public static final String PROP_BINDING_PREFIX = "prop";
 
     private TapestryConstants()
     {

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java Mon Feb 19 16:48:34 2007
@@ -34,14 +34,10 @@
 import org.apache.tapestry.corelib.mixins.DiscardBody;
 import org.apache.tapestry.corelib.mixins.RenderDisabled;
 import org.apache.tapestry.corelib.mixins.RenderInformals;
-import org.apache.tapestry.internal.InternalConstants;
 import org.apache.tapestry.internal.TapestryUtils;
-import org.apache.tapestry.internal.bindings.LiteralBinding;
 import org.apache.tapestry.internal.services.FormParameterLookup;
 import org.apache.tapestry.ioc.Messages;
-import org.apache.tapestry.ioc.services.PropertyAccess;
-import org.apache.tapestry.runtime.Component;
-import org.apache.tapestry.services.BindingSource;
+import org.apache.tapestry.services.DefaultComponentParameterBindingSource;
 import org.apache.tapestry.services.FormSupport;
 import org.apache.tapestry.services.PageRenderSupport;
 
@@ -146,13 +142,10 @@
     @Inject("service:tapestry.internal.FormParameterLookup")
     private FormParameterLookup _paramLookup;
 
-    @Inject("infrastructure:BindingSource")
-    private BindingSource _bindingSource;
+    @Inject("infrastructure:DefaultComponentParameterBindingSource")
+    private DefaultComponentParameterBindingSource _defaultBindingSource;
 
-    @Inject("infrastructure:PropertyAccess")
-    private PropertyAccess _propertyAccess;
-
-    final Binding defaultLabel()
+    final String defaultLabel()
     {
         Messages containerMessages = _resources.getContainer().getComponentResources()
                 .getMessages();
@@ -161,12 +154,8 @@
 
         String key = componentId + "-label";
 
-        String label = containerMessages.contains(key) ? containerMessages.get(key) : TapestryUtils
+        return containerMessages.contains(key) ? containerMessages.get(key) : TapestryUtils
                 .toUserPresentable(componentId);
-
-        // Bypassing the BindingSource for this ...
-
-        return new LiteralBinding("default label", label, null);
     }
 
     public final String getLabel()
@@ -231,24 +220,7 @@
      */
     protected final Binding createDefaultParameterBinding(String parameterName)
     {
-        String componentId = _resources.getId();
-
-        Component container = _resources.getContainer();
-
-        // Only provide a default binding if the container actually contains the property.
-        // This sets up an error condition for when the value parameter is not bound, and
-        // the binding can't be deduced.
-
-        if (_propertyAccess.getAdapter(container).getPropertyAdapter(componentId) == null)
-            return null;
-
-        ComponentResources containerResources = _resources.getContainerResources();
-
-        return _bindingSource.newBinding(
-                "default " + parameterName,
-                containerResources,
-                InternalConstants.PROP_BINDING_PREFIX,
-                componentId);
+        return _defaultBindingSource.createDefaultBinding(parameterName, _resources);
     }
 
     /**

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/OutputRaw.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/OutputRaw.java?view=auto&rev=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/OutputRaw.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/OutputRaw.java Mon Feb 19 16:48:34 2007
@@ -0,0 +1,68 @@
+// 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.corelib.components;
+
+import org.apache.tapestry.Binding;
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.annotations.Inject;
+import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.services.DefaultComponentParameterBindingSource;
+
+/**
+ * Used to output raw markup to the client. Unlike, say, an expansion, the output from OutputRaw is
+ * unfiltered, with any special characters or entities left exactly as is. This is used in
+ * situations where the markup is provided externally, rather than constructed within Tapestry.
+ * 
+ * @see MarkupWriter#writeRaw(String)
+ */
+public class OutputRaw
+{
+    /**
+     * The value to to render. If unbound, and a property of the container matches the component's
+     * id, then that property will be the source of the value.
+     */
+    @Parameter(required = true)
+    private String _value;
+
+    @Inject("infrastructure:DefaultComponentParameterBindingSource")
+    private DefaultComponentParameterBindingSource _defaultBindingSource;
+
+    @Inject
+    private ComponentResources _resources;
+
+    Binding defaultValue()
+    {
+        return _defaultBindingSource.createDefaultBinding("value", _resources);
+    }
+
+    boolean beginRender(MarkupWriter writer)
+    {
+        if (_value != null && _value.length() > 0)
+            writer.writeRaw(_value);
+
+        // Abort the rest of the render.
+
+        return false;
+    }
+
+    // For testing:
+
+    void setValue(String value)
+    {
+        _value = value;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Element.java Mon Feb 19 16:48:34 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -173,11 +173,24 @@
         return child;
     }
 
-    public Comment comment(String text)
+    public void comment(String text)
     {
-        return newChild(new Comment(this, text));
+        newChild(new Comment(this, text));
     }
 
+    public void raw(String text)
+    {
+        newChild(new Raw(this, text));
+    }
+
+    /**
+     * Adds and returns a new text node (the text node is returned so that
+     * {@link Text#write(String)} or [@link {@link Text#writef(String, Object[])} may be invoked .
+     * 
+     * @param text
+     *            initial text for the node
+     * @return the new Text node
+     */
     public Text text(String text)
     {
         return newChild(new Text(this, _document, text));

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Raw.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Raw.java?view=auto&rev=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Raw.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/dom/Raw.java Mon Feb 19 16:48:34 2007
@@ -0,0 +1,41 @@
+// 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.dom;
+
+import java.io.PrintWriter;
+
+/**
+ * A specialized node in the document tree that contains raw markup to be printed to the client
+ * exactly as-is.
+ */
+public final class Raw extends Node
+{
+    private final String _text;
+
+    Raw(Node container, String text)
+    {
+        super(container);
+
+        _text = text;
+    }
+
+    /** Prints the text exactly as is, no translations, filtering, etc. */
+    @Override
+    public void toMarkup(PrintWriter writer)
+    {
+        writer.print(_text);
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalConstants.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalConstants.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalConstants.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalConstants.java Mon Feb 19 16:48:34 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -21,12 +21,6 @@
      * classes are in the pages, components and mixins sub-packages.
      */
     public static final String TAPESTRY_APP_PACKAGE_PARAM = "tapestry.app-package";
-
-    /** Binding expression prefix used for literal strings. */
-    public static final String LITERAL_BINDING_PREFIX = "literal";
-
-    /** Binding expression prefix used to bind to a property of the component. */
-    public static final String PROP_BINDING_PREFIX = "prop";
 
     /**
      * The extension used for Tapestry component template files. Template files are well-formed XML

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/MarkupWriterImpl.java Mon Feb 19 16:48:34 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -137,6 +137,15 @@
         _currentText = null;
 
         return _current;
+    }
+
+    public void writeRaw(String text)
+    {
+        ensureCurrentElement();
+
+        _currentText = null;
+
+        _current.raw(text);
     }
 
     public Element end()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageElementFactoryImpl.java Mon Feb 19 16:48:34 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -17,7 +17,7 @@
 import org.apache.tapestry.Binding;
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.MarkupWriter;
-import org.apache.tapestry.internal.InternalConstants;
+import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.internal.parser.AttributeToken;
 import org.apache.tapestry.internal.parser.CommentToken;
 import org.apache.tapestry.internal.parser.ExpansionToken;
@@ -107,7 +107,7 @@
                 "expansion",
                 componentResources,
                 componentResources,
-                InternalConstants.PROP_BINDING_PREFIX,
+                TapestryConstants.PROP_BINDING_PREFIX,
                 token.getExpression(),
                 token.getLocation());
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderProcessor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderProcessor.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderProcessor.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/PageLoaderProcessor.java Mon Feb 19 16:48:34 2007
@@ -24,7 +24,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.Binding;
 import org.apache.tapestry.ComponentResources;
-import org.apache.tapestry.internal.InternalConstants;
+import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.internal.bindings.LiteralBinding;
 import org.apache.tapestry.internal.parser.AttributeToken;
 import org.apache.tapestry.internal.parser.BlockToken;
@@ -130,7 +130,7 @@
         String defaultBindingPrefix = determineDefaultBindingPrefix(
                 component,
                 name,
-                InternalConstants.LITERAL_BINDING_PREFIX);
+                TapestryConstants.LITERAL_BINDING_PREFIX);
 
         Binding binding = _bindingSource.newBinding(
                 "parameter " + name,
@@ -173,7 +173,7 @@
             String defaultBindingPrefix = determineDefaultBindingPrefix(
                     component,
                     name,
-                    InternalConstants.PROP_BINDING_PREFIX);
+                    TapestryConstants.PROP_BINDING_PREFIX);
 
             // At some point we may add meta data to control what the default prefix is within a
             // component.

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImpl.java?view=auto&rev=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImpl.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImpl.java Mon Feb 19 16:48:34 2007
@@ -0,0 +1,61 @@
+// 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.structure;
+
+import org.apache.tapestry.Binding;
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.TapestryConstants;
+import org.apache.tapestry.ioc.services.PropertyAccess;
+import org.apache.tapestry.runtime.Component;
+import org.apache.tapestry.services.BindingSource;
+import org.apache.tapestry.services.DefaultComponentParameterBindingSource;
+
+public class DefaultComponentParameterBindingSourceImpl implements
+        DefaultComponentParameterBindingSource
+{
+    private final PropertyAccess _propertyAccess;
+
+    private final BindingSource _bindingSource;
+
+    public DefaultComponentParameterBindingSourceImpl(PropertyAccess propertyAccess,
+            BindingSource bindingSource)
+    {
+        _propertyAccess = propertyAccess;
+        _bindingSource = bindingSource;
+    }
+
+    public Binding createDefaultBinding(String parameterName, ComponentResources componentResources)
+    {
+        String componentId = componentResources.getId();
+
+        Component container = componentResources.getContainer();
+
+        // Only provide a default binding if the container actually contains the property.
+        // This sets up an error condition for when the parameter is not bound, and
+        // the binding can't be deduced.
+
+        if (_propertyAccess.getAdapter(container).getPropertyAdapter(componentId) == null)
+            return null;
+
+        ComponentResources containerResources = componentResources.getContainerResources();
+
+        return _bindingSource.newBinding(
+                "default " + parameterName,
+                containerResources,
+                TapestryConstants.PROP_BINDING_PREFIX,
+                componentId);
+    }
+
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/DefaultComponentParameterBindingSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/DefaultComponentParameterBindingSource.java?view=auto&rev=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/DefaultComponentParameterBindingSource.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/DefaultComponentParameterBindingSource.java Mon Feb 19 16:48:34 2007
@@ -0,0 +1,37 @@
+// 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.services;
+
+import org.apache.tapestry.Binding;
+import org.apache.tapestry.ComponentResources;
+
+/**
+ * An assistant to components that wish to generate a binding matching the name of a property of
+ * their container, should such a property exist.
+ */
+public interface DefaultComponentParameterBindingSource
+{
+    /**
+     * Checks to see if the container of the component contains a property matching the component's
+     * id. If so, a binding for that property is returned.
+     * 
+     * @param parameterName
+     *            the name of the parameter
+     * @param componentResources
+     *            the resources of the component for which a binding is needed
+     * @return the binding, or null if the container does not have a matching property
+     */
+    Binding createDefaultBinding(String parameterName, ComponentResources componentResources);
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java Mon Feb 19 16:48:34 2007
@@ -30,6 +30,7 @@
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.SelectModel;
 import org.apache.tapestry.StreamResponse;
+import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.Translator;
 import org.apache.tapestry.Validator;
 import org.apache.tapestry.annotations.AfterRender;
@@ -49,7 +50,6 @@
 import org.apache.tapestry.dom.DefaultMarkupModel;
 import org.apache.tapestry.dom.Document;
 import org.apache.tapestry.grid.GridDataSource;
-import org.apache.tapestry.internal.InternalConstants;
 import org.apache.tapestry.internal.TapestryUtils;
 import org.apache.tapestry.internal.beaneditor.PrimitiveFieldConstraintGenerator;
 import org.apache.tapestry.internal.beaneditor.ValidateAnnotationConstraintGenerator;
@@ -149,6 +149,7 @@
 import org.apache.tapestry.internal.services.UpdateListenerHub;
 import org.apache.tapestry.internal.services.ValidationConstraintGeneratorImpl;
 import org.apache.tapestry.internal.services.ValidationMessagesSourceImpl;
+import org.apache.tapestry.internal.structure.DefaultComponentParameterBindingSourceImpl;
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.IOCUtilities;
 import org.apache.tapestry.ioc.MappedConfiguration;
@@ -560,6 +561,7 @@
                 ComponentEventResultProcessor.class,
                 ComponentMessagesSource.class,
                 ComponentSource.class,
+                DefaultComponentParameterBindingSource.class,
                 Environment.class,
                 FieldValidatorDefaultSource.class,
                 FieldValidatorSource.class,
@@ -707,8 +709,8 @@
             @Inject("infrastructure:TranslatorSource")
             TranslatorSource translatorSource)
     {
-        configuration.add(InternalConstants.LITERAL_BINDING_PREFIX, new LiteralBindingFactory());
-        configuration.add(InternalConstants.PROP_BINDING_PREFIX, propBindingFactory);
+        configuration.add(TapestryConstants.LITERAL_BINDING_PREFIX, new LiteralBindingFactory());
+        configuration.add(TapestryConstants.PROP_BINDING_PREFIX, propBindingFactory);
         configuration.add("component", new ComponentBindingFactory());
         configuration.add("message", new MessageBindingFactory());
         configuration.add("validate", new ValidateBindingFactory(fieldValidatorSource));
@@ -1450,5 +1452,12 @@
         configuration.add(
                 PersistentFieldManagerImpl.META_KEY,
                 PersistentFieldManagerImpl.DEFAULT_STRATEGY);
+    }
+
+    public DefaultComponentParameterBindingSource buildDefaultComponentParameterBindingSource(
+            @Inject("infrastructure:BindingSource")
+            BindingSource bindingSource)
+    {
+        return new DefaultComponentParameterBindingSourceImpl(_propertyAccess, bindingSource);
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java Mon Feb 19 16:48:34 2007
@@ -831,4 +831,14 @@
     {
         expect(model.getMeta(key)).andReturn(value).atLeastOnce();
     }
+
+    protected void train_newBinding(BindingSource bindingSource, String description, ComponentResources componentResources, String defaultBindingPrefix, String expression, Binding binding)
+    {
+        expect(
+                bindingSource.newBinding(
+                        description,
+                        componentResources,
+                        defaultBindingPrefix,
+                        expression)).andReturn(binding);
+    }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/corelib/components/OutputRawTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/corelib/components/OutputRawTest.java?view=auto&rev=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/corelib/components/OutputRawTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/corelib/components/OutputRawTest.java Mon Feb 19 16:48:34 2007
@@ -0,0 +1,72 @@
+// 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.corelib.components;
+
+import org.apache.tapestry.MarkupWriter;
+import org.apache.tapestry.test.TapestryTestCase;
+import org.testng.annotations.Test;
+
+public class OutputRawTest extends TapestryTestCase
+{
+    @Test
+    public void value_is_null()
+    {
+        MarkupWriter writer = newMarkupWriter();
+
+        replay();
+
+        OutputRaw component = new OutputRaw();
+
+        assertFalse(component.beginRender(writer));
+
+        verify();
+    }
+
+    @Test
+    public void value_is_empty_string()
+    {
+        MarkupWriter writer = newMarkupWriter();
+
+        replay();
+
+        OutputRaw component = new OutputRaw();
+
+        component.setValue("");
+
+        assertFalse(component.beginRender(writer));
+
+        verify();
+    }
+
+    @Test
+    public void value_is_non_blank()
+    {
+        String value = "&nbsp;";
+
+        MarkupWriter writer = newMarkupWriter();
+
+        writer.writeRaw(value);
+
+        replay();
+
+        OutputRaw component = new OutputRaw();
+
+        component.setValue(value);
+
+        assertFalse(component.beginRender(writer));
+
+        verify();
+    }
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/dom/DOMTest.java Mon Feb 19 16:48:34 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -340,5 +340,24 @@
         root.forceAttributes("hi", "bit", "gnip", null);
 
         assertEquals(root.toString(), "<fred hi=\"bit\"/>");
+    }
+
+    @Test
+    public void raw_output()
+    {
+        Document d = new Document(new XMLMarkupModel());
+
+        Element root = d.newRootElement("fred");
+
+        Element em = root.element("em");
+
+        em.text("<");
+        em.raw("&nbsp;");
+        em.text(">");
+
+        // The '<' and '>' are filtered into entities, but the '&' in &nbsp; is left alone (left
+        // raw).
+
+        assertEquals(root.toString(), "<fred><em>&lt;&nbsp;&gt;</em></fred>");
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java Mon Feb 19 16:48:34 2007
@@ -17,7 +17,7 @@
 import java.util.Arrays;
 
 import org.apache.commons.logging.Log;
-import org.apache.tapestry.internal.InternalConstants;
+import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.Resource;
 import org.apache.tapestry.model.ComponentModel;
@@ -69,13 +69,13 @@
 
         String parameterName = "value";
 
-        model.addParameter(parameterName, true, InternalConstants.PROP_BINDING_PREFIX);
+        model.addParameter(parameterName, true, TapestryConstants.PROP_BINDING_PREFIX);
 
         ParameterModel pm = model.getParameterModel(parameterName);
 
         assertEquals(pm.getName(), parameterName);
         assertEquals(true, pm.isRequired());
-        assertEquals(pm.getDefaultBindingPrefix(), InternalConstants.PROP_BINDING_PREFIX);
+        assertEquals(pm.getDefaultBindingPrefix(), TapestryConstants.PROP_BINDING_PREFIX);
 
         assertEquals(model.getDeclaredParameterNames(), Arrays.asList(parameterName));
 
@@ -100,9 +100,9 @@
 
         MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, log, r, null);
 
-        model.addParameter("fred", true, InternalConstants.PROP_BINDING_PREFIX);
-        model.addParameter("wilma", true, InternalConstants.PROP_BINDING_PREFIX);
-        model.addParameter("barney", true, InternalConstants.PROP_BINDING_PREFIX);
+        model.addParameter("fred", true, TapestryConstants.PROP_BINDING_PREFIX);
+        model.addParameter("wilma", true, TapestryConstants.PROP_BINDING_PREFIX);
+        model.addParameter("barney", true, TapestryConstants.PROP_BINDING_PREFIX);
 
         assertEquals(model.getDeclaredParameterNames(), Arrays.asList("barney", "fred", "wilma"));
 
@@ -123,9 +123,9 @@
 
         MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, log, r, parent);
 
-        model.addParameter("fred", true, InternalConstants.PROP_BINDING_PREFIX);
-        model.addParameter("wilma", true, InternalConstants.PROP_BINDING_PREFIX);
-        model.addParameter("barney", true, InternalConstants.PROP_BINDING_PREFIX);
+        model.addParameter("fred", true, TapestryConstants.PROP_BINDING_PREFIX);
+        model.addParameter("wilma", true, TapestryConstants.PROP_BINDING_PREFIX);
+        model.addParameter("barney", true, TapestryConstants.PROP_BINDING_PREFIX);
 
         assertEquals(model.getDeclaredParameterNames(), Arrays.asList("barney", "fred", "wilma"));
         assertEquals(model.getParameterNames(), Arrays.asList("barney", "betty", "fred", "wilma"));
@@ -143,13 +143,13 @@
 
         MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, log, r, null);
 
-        model.addParameter("fred", true, InternalConstants.PROP_BINDING_PREFIX);
+        model.addParameter("fred", true, TapestryConstants.PROP_BINDING_PREFIX);
 
         try
         {
             // This also helps check that the comparison is caseless!
             
-            model.addParameter("Fred", true, InternalConstants.PROP_BINDING_PREFIX);
+            model.addParameter("Fred", true, TapestryConstants.PROP_BINDING_PREFIX);
             unreachable();
         }
         catch (IllegalArgumentException ex)
@@ -186,7 +186,7 @@
         replay();
 
         MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, log, r, null);
-        model.addParameter("fred", true, InternalConstants.PROP_BINDING_PREFIX);
+        model.addParameter("fred", true, TapestryConstants.PROP_BINDING_PREFIX);
 
         assertNull(model.getParameterModel("barney"));
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/MarkupWriterImplTest.java Mon Feb 19 16:48:34 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 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.
@@ -208,5 +208,19 @@
         writer.attributes("action", link);
 
         verify();
+    }
+
+    @Test
+    public void write_raw()
+    {
+        MarkupWriter w = new MarkupWriterImpl();
+
+        w.element("root");
+        w.write("<");
+        w.writeRaw("&nbsp;");
+        w.write(">");
+        w.end();
+
+        assertEquals(w.toString(), "<root>&lt;&nbsp;&gt;</root>");
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ParameterWorkerTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ParameterWorkerTest.java?view=diff&rev=509396&r1=509395&r2=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ParameterWorkerTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ParameterWorkerTest.java Mon Feb 19 16:48:34 2007
@@ -21,8 +21,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.Binding;
+import org.apache.tapestry.TapestryConstants;
 import org.apache.tapestry.internal.InternalComponentResources;
-import org.apache.tapestry.internal.InternalConstants;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.internal.services.PropertyAccessImpl;
 import org.apache.tapestry.ioc.services.PropertyAccess;
@@ -464,7 +464,7 @@
 
         MutableComponentModel model = newMutableComponentModel();
 
-        model.addParameter("value", false, InternalConstants.PROP_BINDING_PREFIX);
+        model.addParameter("value", false, TapestryConstants.PROP_BINDING_PREFIX);
 
         Runnable phaseTwoTraining = new Runnable()
         {
@@ -476,7 +476,7 @@
                         source.newBinding(
                                 "default value",
                                 resources,
-                                InternalConstants.PROP_BINDING_PREFIX,
+                                TapestryConstants.PROP_BINDING_PREFIX,
                                 "literal:greeting")).andReturn(binding);
 
                 resources.bindParameter("value", binding);
@@ -515,7 +515,7 @@
 
         MutableComponentModel model = newMutableComponentModel();
 
-        model.addParameter("value", false, InternalConstants.PROP_BINDING_PREFIX);
+        model.addParameter("value", false, TapestryConstants.PROP_BINDING_PREFIX);
 
         Runnable phaseTwoTraining = new Runnable()
         {
@@ -567,11 +567,11 @@
     {
         MutableComponentModel model = newMutableComponentModel();
 
-        model.addParameter("invariantObject", false, InternalConstants.PROP_BINDING_PREFIX);
-        model.addParameter("invariantPrimitive", false, InternalConstants.PROP_BINDING_PREFIX);
-        model.addParameter("object", false, InternalConstants.PROP_BINDING_PREFIX);
-        model.addParameter("primitive", true, InternalConstants.PROP_BINDING_PREFIX);
-        model.addParameter("uncached", false, InternalConstants.LITERAL_BINDING_PREFIX);
+        model.addParameter("invariantObject", false, TapestryConstants.PROP_BINDING_PREFIX);
+        model.addParameter("invariantPrimitive", false, TapestryConstants.PROP_BINDING_PREFIX);
+        model.addParameter("object", false, TapestryConstants.PROP_BINDING_PREFIX);
+        model.addParameter("primitive", true, TapestryConstants.PROP_BINDING_PREFIX);
+        model.addParameter("uncached", false, TapestryConstants.LITERAL_BINDING_PREFIX);
 
         Runnable phaseTwoTraining = new Runnable()
         {

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImplTest.java?view=auto&rev=509396
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImplTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/DefaultComponentParameterBindingSourceImplTest.java Mon Feb 19 16:48:34 2007
@@ -0,0 +1,129 @@
+// 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.structure;
+
+import org.apache.tapestry.Binding;
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.TapestryConstants;
+import org.apache.tapestry.ioc.services.ClassPropertyAdapter;
+import org.apache.tapestry.ioc.services.PropertyAccess;
+import org.apache.tapestry.ioc.services.PropertyAdapter;
+import org.apache.tapestry.runtime.Component;
+import org.apache.tapestry.services.BindingSource;
+import org.apache.tapestry.services.DefaultComponentParameterBindingSource;
+import org.apache.tapestry.test.TapestryTestCase;
+import org.testng.annotations.Test;
+
+public class DefaultComponentParameterBindingSourceImplTest extends TapestryTestCase
+{
+    @Test
+    public void no_matching_property()
+    {
+        String parameterName = "myparam";
+
+        String id = "mycomponentid";
+
+        ComponentResources resources = newComponentResources();
+        Component container = newComponent();
+        PropertyAccess access = newPropertyAccess();
+        ClassPropertyAdapter classPropertyAdapter = newClassPropertyAdapter();
+        BindingSource bindingSource = newBindingSource();
+
+        train_getId(resources, id);
+        train_getContainer(resources, container);
+
+        train_getAdapter(access, container, classPropertyAdapter);
+        train_getPropertyAdapter(classPropertyAdapter, id, null);
+
+        replay();
+
+        DefaultComponentParameterBindingSource source = new DefaultComponentParameterBindingSourceImpl(
+                access, bindingSource);
+
+        assertNull(source.createDefaultBinding(parameterName, resources));
+
+        verify();
+    }
+
+    @Test
+    public void property_exists()
+    {
+        String parameterName = "myparam";
+
+        String id = "mycomponentid";
+
+        ComponentResources resources = newComponentResources();
+        Component container = newComponent();
+        PropertyAccess access = newPropertyAccess();
+        ClassPropertyAdapter classPropertyAdapter = newClassPropertyAdapter();
+        PropertyAdapter propertyAdapter = newPropertyAdapter();
+        BindingSource bindingSource = newBindingSource();
+        Binding binding = newBinding();
+        ComponentResources containerResources = newComponentResources();
+
+        train_getId(resources, id);
+        train_getContainer(resources, container);
+
+        train_getAdapter(access, container, classPropertyAdapter);
+        train_getPropertyAdapter(classPropertyAdapter, id, propertyAdapter);
+
+        train_getContainerResources(resources, containerResources);
+
+        train_newBinding(
+                bindingSource,
+                "default myparam",
+                containerResources,
+                TapestryConstants.PROP_BINDING_PREFIX,
+                id,
+                binding);
+
+        replay();
+
+        DefaultComponentParameterBindingSource source = new DefaultComponentParameterBindingSourceImpl(
+                access, bindingSource);
+
+        assertSame(source.createDefaultBinding(parameterName, resources), binding);
+
+        verify();
+    }
+
+    protected final PropertyAdapter newPropertyAdapter()
+    {
+        return newMock(PropertyAdapter.class);
+    }
+
+    protected final ClassPropertyAdapter newClassPropertyAdapter()
+    {
+        return newMock(ClassPropertyAdapter.class);
+    }
+
+    protected final PropertyAccess newPropertyAccess()
+    {
+        return newMock(PropertyAccess.class);
+    }
+
+    protected final void train_getPropertyAdapter(ClassPropertyAdapter classPropertyAdapter,
+            String propertyName, PropertyAdapter propertyAdapter)
+    {
+        expect(classPropertyAdapter.getPropertyAdapter(propertyName)).andReturn(propertyAdapter)
+                .atLeastOnce();
+    }
+
+    protected final void train_getAdapter(PropertyAccess access, Object object,
+            ClassPropertyAdapter classPropertyAdapter)
+    {
+        expect(access.getAdapter(object)).andReturn(classPropertyAdapter);
+    }
+}



Mime
View raw message