tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Howard Lewis Ship" <hls...@gmail.com>
Subject Re: svn commit: r686020 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/annotations/ main/java/org/apache/tapestry5/corelib/components/ main/java/org/apache/tapestry5/internal/transform/ test/java/org/apache/tapestry5
Date Thu, 14 Aug 2008 21:45:06 GMT
Very cool!  However, there's a page in the cookbook about this:

http://tapestry.formos.com/nightly/tapestry5/cookbook/defaultparameter.html



On Thu, Aug 14, 2008 at 1:22 PM,  <drobiazko@apache.org> wrote:
> Author: drobiazko
> Date: Thu Aug 14 13:22:52 2008
> New Revision: 686020
>
> URL: http://svn.apache.org/viewvc?rev=686020&view=rev
> Log:
> TAPESTRY-2137: The common idiom of connecting a component's id to a container property
should be easier: an attribute of the @Parameter annotation
>
> Modified:
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/annotations/Parameter.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanDisplay.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditForm.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Output.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/OutputRaw.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Radio.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java
>    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
>    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/transform/ParameterWorkerTest.java
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/annotations/Parameter.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/annotations/Parameter.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/annotations/Parameter.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/annotations/Parameter.java
Thu Aug 14 13:22:52 2008
> @@ -84,4 +84,10 @@
>      * have more than a single principal parameter.
>      */
>     boolean principal() default false;
> +
> +    /**
> +     * Used to create a binding to be used as a parameter default without to provide
a default binding method.
> +     * If true, then the container's property matching the component id is used to bind
the parameter.
> +     */
> +    boolean autoconnect() default false;
>  }
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/AjaxFormLoop.java
Thu Aug 14 13:22:52 2008
> @@ -49,7 +49,7 @@
>     /**
>      * The objects to iterate over (passed to the internal Loop component).
>      */
> -    @Parameter(required = true)
> +    @Parameter(required = true, autoconnect = true)
>     private Iterable source;
>
>     /**
> @@ -123,8 +123,6 @@
>     @Inject
>     private ComponentClassCache componentClassCache;
>
> -    @Inject
> -    private ComponentDefaultProvider componentDefaultProvider;
>
>     @Inject
>     private PageRenderQueue pageRenderQueue;
> @@ -166,11 +164,6 @@
>         }
>     };
>
> -    Binding defaultSource()
> -    {
> -        return componentDefaultProvider.defaultBinding("source", resources);
> -    }
> -
>
>     String defaultElement()
>     {
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanDisplay.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanDisplay.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanDisplay.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanDisplay.java
Thu Aug 14 13:22:52 2008
> @@ -14,7 +14,6 @@
>
>  package org.apache.tapestry5.corelib.components;
>
> -import org.apache.tapestry5.Binding;
>  import org.apache.tapestry5.BindingConstants;
>  import org.apache.tapestry5.ComponentResources;
>  import org.apache.tapestry5.annotations.Parameter;
> @@ -25,7 +24,6 @@
>  import org.apache.tapestry5.internal.beaneditor.BeanModelUtils;
>  import org.apache.tapestry5.ioc.annotations.Inject;
>  import org.apache.tapestry5.services.BeanModelSource;
> -import org.apache.tapestry5.services.ComponentDefaultProvider;
>
>  /**
>  * Used to display the properties of a bean, using an underlying {@link BeanModel}. The
output definition list: a
> @@ -49,7 +47,7 @@
>      * The object to be rendered; if not explicitly bound, a default binding to a property
whose name matches this
>      * component's id will be used.
>      */
> -    @Parameter(required = true, allowNull = false)
> +    @Parameter(required = true, allowNull = false, autoconnect = true)
>     @Property(write = false)
>     private Object object;
>
> @@ -107,10 +105,6 @@
>     @Parameter(defaultPrefix = BindingConstants.LITERAL)
>     private String add;
>
> -
> -    @Inject
> -    private ComponentDefaultProvider defaultProvider;
> -
>     @Inject
>     private ComponentResources resources;
>
> @@ -120,14 +114,6 @@
>     @Property
>     private String propertyName;
>
> -    /**
> -     * Defaults the object parameter to a property of the container matching the BeanEditForm's
id.
> -     */
> -    Binding defaultObject()
> -    {
> -        return defaultProvider.defaultBinding("object", resources);
> -    }
> -
>     void setupRender()
>     {
>         if (model == null) model = modelSource.create(object.getClass(), false,
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditForm.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditForm.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditForm.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditForm.java
Thu Aug 14 13:22:52 2008
> @@ -23,7 +23,6 @@
>  import org.apache.tapestry5.internal.beaneditor.BeanModelUtils;
>  import org.apache.tapestry5.ioc.annotations.Inject;
>  import org.apache.tapestry5.services.BeanModelSource;
> -import org.apache.tapestry5.services.ComponentDefaultProvider;
>
>  /**
>  * A component that creates an entire form editing the properties of a particular bean.
Inspired by <a
> @@ -59,7 +58,7 @@
>      * value is ready to be read or updated. Often, the BeanEditForm can create the object
as needed (assuming a public,
>      * no arguments constructor).  The object property defaults to a property with the
same name as the component id.
>      */
> -    @Parameter(required = true)
> +    @Parameter(required = true, autoconnect = true)
>     @Property
>     private Object object;
>
> @@ -121,22 +120,11 @@
>     private BeanModel model;
>
>     @Inject
> -    private ComponentDefaultProvider defaultProvider;
> -
> -    @Inject
>     private ComponentResources resources;
>
>     @Inject
>     private BeanModelSource beanModelSource;
>
> -    /**
> -     * Defaults the object parameter to a property of the container matching the BeanEditForm's
id.
> -     */
> -    Binding defaultObject()
> -    {
> -        return defaultProvider.defaultBinding("object", resources);
> -    }
> -
>
>     void onPrepareFromForm()
>     {
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/BeanEditor.java
Thu Aug 14 13:22:52 2008
> @@ -25,7 +25,6 @@
>  import org.apache.tapestry5.ioc.annotations.Inject;
>  import org.apache.tapestry5.ioc.internal.util.TapestryException;
>  import org.apache.tapestry5.services.BeanModelSource;
> -import org.apache.tapestry5.services.ComponentDefaultProvider;
>  import org.apache.tapestry5.services.FormSupport;
>
>  /**
> @@ -56,7 +55,7 @@
>      * for the component is submitted. Typically, the container will listen for a "prepare"
event, in order to ensure
>      * that a non-null value is ready to be read or updated.
>      */
> -    @Parameter
> +    @Parameter(autoconnect = true)
>     private Object object;
>
>     /**
> @@ -111,9 +110,6 @@
>     private BeanModelSource modelSource;
>
>     @Inject
> -    private ComponentDefaultProvider defaultProvider;
> -
> -    @Inject
>     private ComponentResources resources;
>
>     @Environmental
> @@ -124,14 +120,6 @@
>     @Property
>     private String propertyName;
>
> -    /**
> -     * Defaults the object parameter to a property of the container matching the BeanEditForm's
id.
> -     */
> -    Binding defaultObject()
> -    {
> -        return defaultProvider.defaultBinding("object", resources);
> -    }
> -
>     // Needed for testing as well
>
>     public Object getObject()
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Loop.java
Thu Aug 14 13:22:52 2008
> @@ -18,7 +18,6 @@
>  import org.apache.tapestry5.annotations.*;
>  import org.apache.tapestry5.ioc.annotations.Inject;
>  import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newList;
> -import org.apache.tapestry5.services.ComponentDefaultProvider;
>  import org.apache.tapestry5.services.FormSupport;
>  import org.apache.tapestry5.services.Heartbeat;
>
> @@ -201,7 +200,7 @@
>      * Defines the collection of values for the loop to iterate over. If not specified,
defaults to a property of the
>      * container whose name matches the Loop cmponent's id.
>      */
> -    @Parameter(required = true, principal = true)
> +    @Parameter(required = true, principal = true, autoconnect = true)
>     private Iterable<?> source;
>
>     /**
> @@ -250,13 +249,6 @@
>     @Inject
>     private ComponentResources resources;
>
> -    @Inject
> -    private ComponentDefaultProvider componentDefaultProvider;
> -
> -    Binding defaultSource()
> -    {
> -        return componentDefaultProvider.defaultBinding("source", resources);
> -    }
>
>     String defaultElement()
>     {
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Output.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Output.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Output.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Output.java
Thu Aug 14 13:22:52 2008
> @@ -14,14 +14,12 @@
>
>  package org.apache.tapestry5.corelib.components;
>
> -import org.apache.tapestry5.Binding;
>  import org.apache.tapestry5.ComponentResources;
>  import org.apache.tapestry5.MarkupWriter;
>  import org.apache.tapestry5.annotations.Parameter;
>  import org.apache.tapestry5.annotations.SupportsInformalParameters;
>  import org.apache.tapestry5.ioc.annotations.Inject;
>  import org.apache.tapestry5.ioc.internal.util.InternalUtils;
> -import org.apache.tapestry5.services.ComponentDefaultProvider;
>
>  import java.text.Format;
>
> @@ -35,7 +33,7 @@
>     /**
>      * The value to be output (before formatting). If the formatted value is blank, no
output is produced.
>      */
> -    @Parameter(required = true)
> +    @Parameter(required = true, autoconnect = true)
>     private Object value;
>
>     /**
> @@ -59,15 +57,8 @@
>     private String elementName;
>
>     @Inject
> -    private ComponentDefaultProvider defaultProvider;
> -
> -    @Inject
>     private ComponentResources resources;
>
> -    Binding defaultValue()
> -    {
> -        return defaultProvider.defaultBinding("value", resources);
> -    }
>
>     boolean beginRender(MarkupWriter writer)
>     {
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/OutputRaw.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/OutputRaw.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/OutputRaw.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/OutputRaw.java
Thu Aug 14 13:22:52 2008
> @@ -14,12 +14,10 @@
>
>  package org.apache.tapestry5.corelib.components;
>
> -import org.apache.tapestry5.Binding;
>  import org.apache.tapestry5.ComponentResources;
>  import org.apache.tapestry5.MarkupWriter;
>  import org.apache.tapestry5.annotations.Parameter;
>  import org.apache.tapestry5.ioc.annotations.Inject;
> -import org.apache.tapestry5.services.ComponentDefaultProvider;
>
>  /**
>  * Used to output raw markup to the client. Unlike, say, an expansion, the output from
OutputRaw is unfiltered, with any
> @@ -34,20 +32,12 @@
>      * 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)
> +    @Parameter(required = true, autoconnect = true)
>     private String value;
>
>     @Inject
> -    private ComponentDefaultProvider defaultProvider;
> -
> -    @Inject
>     private ComponentResources resources;
>
> -    Binding defaultValue()
> -    {
> -        return defaultProvider.defaultBinding("value", resources);
> -    }
> -
>     boolean beginRender(MarkupWriter writer)
>     {
>         if (value != null && value.length() > 0) writer.writeRaw(value);
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Radio.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Radio.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Radio.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Radio.java
Thu Aug 14 13:22:52 2008
> @@ -48,7 +48,7 @@
>      * The value associated with this radio button. This is used to determine which radio
button will be selected when
>      * the page is rendered, and also becomes the value assigned when the form is submitted.
>      */
> -    @Parameter(required = true, principal = true)
> +    @Parameter(required = true, principal = true, autoconnect = true)
>     private Object value;
>
>     @Inject
> @@ -88,11 +88,6 @@
>         return defaultProvider.defaultLabel(resources);
>     }
>
> -    Binding defaultValue()
> -    {
> -        return defaultProvider.defaultBinding("value", resources);
> -    }
> -
>     /**
>      * Returns the control name provided by the containing {@link org.apache.tapestry5.RadioContainer}.
>      */
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/RadioGroup.java
Thu Aug 14 13:22:52 2008
> @@ -29,7 +29,7 @@
>     /**
>      * The property read and updated by the group as a whole.
>      */
> -    @Parameter(required = true, principal = true)
> +    @Parameter(required = true, principal = true, autoconnect = true)
>     private Object value;
>
>     /**
> @@ -74,11 +74,6 @@
>
>     private String controlName;
>
> -    final Binding defaultValue()
> -    {
> -        return defaultProvider.defaultBinding("value", resources);
> -    }
> -
>     String defaultLabel()
>     {
>         return defaultProvider.defaultLabel(resources);
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/ParameterWorker.java
Thu Aug 14 13:22:52 2008
> @@ -35,10 +35,13 @@
>     private static final String BIND_METHOD_NAME = ParameterWorker.class.getName() +
".bind";
>
>     private final BindingSource bindingSource;
> +
> +    private ComponentDefaultProvider defaultProvider;
>
> -    public ParameterWorker(BindingSource bindingSource)
> +    public ParameterWorker(BindingSource bindingSource, ComponentDefaultProvider defaultProvider)
>     {
>         this.bindingSource = bindingSource;
> +        this.defaultProvider = defaultProvider;
>     }
>
>     public void transform(final ClassTransformation transformation, MutableComponentModel
model)
> @@ -90,7 +93,7 @@
>
>         String invariantFieldName = addParameterSetup(name, annotation.defaultPrefix(),
annotation.value(),
>                                                       parameterName, cachedFieldName,
cache, type, resourcesFieldName,
> -                                                      transformation);
> +                                                      transformation, annotation.autoconnect());
>
>         addReaderMethod(name, cachedFieldName, invariantFieldName, cache, parameterName,
type, resourcesFieldName,
>                         transformation);
> @@ -105,7 +108,7 @@
>      */
>     private String addParameterSetup(String fieldName, String defaultPrefix, String defaultBinding,
>                                      String parameterName, String cachedFieldName, boolean
cache, String fieldType,
> -                                     String resourcesFieldName, ClassTransformation
transformation)
> +                                     String resourcesFieldName, ClassTransformation
transformation, boolean autoconnect)
>     {
>         String defaultFieldName = transformation.addField(Modifier.PRIVATE, fieldType,
fieldName + "_default");
>
> @@ -114,7 +117,7 @@
>         BodyBuilder builder = new BodyBuilder().begin();
>
>         addDefaultBindingSetup(parameterName, defaultPrefix, defaultBinding, resourcesFieldName,
transformation,
> -                               builder);
> +                               builder, autoconnect);
>
>         builder.addln("%s = %s.isInvariant(\"%s\");", invariantFieldName, resourcesFieldName,
parameterName);
>
> @@ -158,7 +161,7 @@
>
>     private void addDefaultBindingSetup(String parameterName, String defaultPrefix, String
defaultBinding,
>                                         String resourcesFieldName, ClassTransformation
transformation,
> -                                        BodyBuilder builder)
> +                                        BodyBuilder builder, boolean autoconnect)
>     {
>         if (InternalUtils.isNonBlank(defaultBinding))
>         {
> @@ -174,6 +177,18 @@
>             return;
>
>         }
> +
> +        if(autoconnect)
> +        {
> +            String defaultProviderFieldName = transformation.addInjectedField(ComponentDefaultProvider.class,
> +                    "defaultProvider", defaultProvider);
> +
> +            builder.addln("if (! %s.isBound(\"%s\"))", resourcesFieldName, parameterName);
> +
> +            builder.addln("  %s.bindParameter(\"%s\", %s.defaultBinding(\"%s\", %s));",
resourcesFieldName,
> +                            parameterName, defaultProviderFieldName, parameterName,
resourcesFieldName);
> +            return;
> +        }
>
>         // If no default binding expression provided in the annotation, then look for
a default
>         // binding method to provide the binding.
>
> Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/transform/ParameterWorkerTest.java
> URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/transform/ParameterWorkerTest.java?rev=686020&r1=686019&r2=686020&view=diff
> ==============================================================================
> --- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/transform/ParameterWorkerTest.java
(original)
> +++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/transform/ParameterWorkerTest.java
Thu Aug 14 13:22:52 2008
> @@ -35,6 +35,7 @@
>  import org.apache.tapestry5.model.MutableComponentModel;
>  import org.apache.tapestry5.runtime.Component;
>  import org.apache.tapestry5.services.BindingSource;
> +import org.apache.tapestry5.services.ComponentDefaultProvider;
>  import org.slf4j.Logger;
>  import org.testng.annotations.AfterClass;
>  import org.testng.annotations.Test;
> @@ -461,6 +462,7 @@
>         final BindingSource source = mockBindingSource();
>         final InternalComponentResources resources = mockInternalComponentResources();
>         final Binding binding = mockBinding();
> +        ComponentDefaultProvider defaultProvider = newMock(ComponentDefaultProvider.class);
>         String boundValue = "howdy!";
>         final Logger logger = mockLogger();
>
> @@ -486,7 +488,7 @@
>         };
>
>         Component component = setupForIntegrationTest(resources, logger, DefaultParameterComponent.class.getName(),
> -                                                      model, source, phaseTwoTraining);
> +                                                      model, source, phaseTwoTraining,
defaultProvider);
>
>         train_isLoaded(resources, true);
>         train_isBound(resources, "value", true);
> @@ -505,6 +507,7 @@
>     {
>         BindingSource source = mockBindingSource();
>         final InternalComponentResources resources = mockInternalComponentResources();
> +        ComponentDefaultProvider defaultProvider = newMock(ComponentDefaultProvider.class);
>         _binding = mockBinding();
>         String boundValue = "yowza!";
>         final Logger logger = mockLogger();
> @@ -531,7 +534,7 @@
>
>         Component component = setupForIntegrationTest(resources, logger,
>                                                       DefaultParameterBindingMethodComponent.class.getName(),
model,
> -                                                      source, phaseTwoTraining);
> +                                                      source, phaseTwoTraining, defaultProvider);
>
>         train_isLoaded(resources, true);
>         train_isBound(resources, "value", true);
> @@ -562,6 +565,7 @@
>     {
>         final Logger logger = mockLogger();
>         MutableComponentModel model = mockMutableComponentModel(logger);
> +        ComponentDefaultProvider defaultProvider = newMock(ComponentDefaultProvider.class);
>
>         model.addParameter("invariantObject", false, true, BindingConstants.PROP);
>         model.addParameter("invariantPrimitive", false, true, BindingConstants.PROP);
> @@ -583,12 +587,12 @@
>         stub_isDebugEnabled(logger, false);
>
>         return setupForIntegrationTest(resources, logger, ParameterComponent.class.getName(),
model,
> -                                       mockBindingSource(), phaseTwoTraining);
> +                                       mockBindingSource(), phaseTwoTraining, defaultProvider);
>     }
>
>     private Component setupForIntegrationTest(InternalComponentResources resources, Logger
logger,
>                                               String componentClassName, MutableComponentModel
model,
> -                                              BindingSource source, Runnable phaseTwoTraining)
throws Exception
> +                                              BindingSource source, Runnable phaseTwoTraining,
ComponentDefaultProvider defaultProvider) throws Exception
>     {
>         ClassFactoryClassPool pool = new ClassFactoryClassPool(contextClassLoader);
>
> @@ -605,7 +609,7 @@
>         InternalClassTransformation transformation = new InternalClassTransformationImpl(cf,
ctClass, null, model,
>                                                                                     
    null);
>
> -        new ParameterWorker(source).transform(transformation, model);
> +        new ParameterWorker(source, defaultProvider).transform(transformation, model);
>
>         verify();
>
>
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org


Mime
View raw message