tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r502308 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/ main/java/org/apache/tapestry/annotations/ main/java/org/apache/tapestry/corelib/base/ main/java/org/apache/tapestry/corelib/components/ main/java/org/...
Date Thu, 01 Feb 2007 18:30:11 GMT
Author: hlship
Date: Thu Feb  1 10:30:09 2007
New Revision: 502308

URL: http://svn.apache.org/viewvc?view=rev&rev=502308
Log:
All parameter defaulter methods to return simple values as well as Binding instances.
Fix a bug where Form rendered a "style" attribute, not a "class" attribute.
Allow for null values inside EnumValueEncoder.
Add method getContainerMessages() to ComponentResources.
Add principal attribute to the Parameter annotation, with corresponding support inside ParamterWorker.
Add a FieldFilter interface, and a findFields() method on ClassTransformation.
Change Select to automatically provide an default SelectModel and/or ValueEncoder when the value parameter's type is an Enum type.

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldFilter.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Department.java
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResources.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumValueEncoder.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/annotations/Parameter.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Label.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Select.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalComponentResourcesCommon.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.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/internal/services/ParameterWorker.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ClassTransformation.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/TapestryTestCase.java
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt
    tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt
    tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/SimpleForm.html
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorSourceImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/ParameterWorkerTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.properties

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResources.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResources.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResources.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ComponentResources.java Thu Feb  1 10:30:09 2007
@@ -48,6 +48,12 @@
     ComponentResources getContainerResources();
 
     /**
+     * Returns the {@link Messages} from the container, or null if this is the root component (with
+     * no container). As a special case, for a mixin, this return the core component's messages.
+     */
+    Messages getContainerMessages();
+
+    /**
      * Returns the page that contains this component. Technically, the page itself is an internal
      * object in Tapestry and this returns the root component of the actual page, but from an
      * application developer point of view, this is the page.
@@ -78,15 +84,15 @@
     Messages getMessages();
 
     /**
-     * Returns the actual type of the bound parameter, or Object.class if the parameter is not
-     * bound. This is primarily used with property bindings, and is used to determine the actual
-     * type of the property, rather than the type of parameter (remember that type coercion
-     * automatically occurs, which can mask significant differences between the parameter type and
-     * the bound property type).
+     * Returns the actual type of the bound parameter, or null if the parameter is not bound. This
+     * is primarily used with property bindings, and is used to determine the actual type of the
+     * property, rather than the type of parameter (remember that type coercion automatically
+     * occurs, which can mask significant differences between the parameter type and the bound
+     * property type).
      * 
      * @see Binding#getBindingType()
      * @param parameterName
-     * @return
+     * @return the type of the bound parameter, or null if the parameter is not bound
      */
     Class getBoundType(String parameterName);
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumValueEncoder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumValueEncoder.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumValueEncoder.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumValueEncoder.java Thu Feb  1 10:30:09 2007
@@ -39,6 +39,9 @@
     @SuppressWarnings("unchecked")
     public Enum toValue(String clientValue)
     {
+        if (clientValue == null)
+            return null;
+
         return Enum.valueOf(_enumType, clientValue);
     }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/annotations/Parameter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/annotations/Parameter.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/annotations/Parameter.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/annotations/Parameter.java Thu Feb  1 10:30:09 2007
@@ -62,8 +62,19 @@
     /**
      * The default binding prefix for the parameter, if no specific binding prefix is provided with
      * the binding. There is <em>rarely</em> a reason to override this. Typically, non-standard
-     * default binding prefixes are paired with specific {@link BindingFactory} implementations,
-     * and used with parameters whose name reflects the binding prefix.
+     * default binding prefixes are paired with specific {@link BindingFactory} implementations, and
+     * used with parameters whose name reflects the binding prefix.
      */
     String defaultPrefix() default "prop";
+
+    /**
+     * Used to mark a parameter as requiring earlier initialization than other parameters. This is
+     * used when default bindings for secondary parameters rely on a principal parameter, which
+     * itself may have a default value. This ensures that the binding for the principal parameter(s)
+     * are initialized, possibly involving a defaulter method, before the secondary parameters are
+     * initialized (as they may need to know if the principal parameter is bound, and what type of
+     * value it is bound to). This is rarely used, and it is highly unlikely a single component
+     * would have more than a single principal parameter.
+     */
+    boolean principal() default false;
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractTextField.java Thu Feb  1 10:30:09 2007
@@ -28,7 +28,6 @@
 import org.apache.tapestry.annotations.Environmental;
 import org.apache.tapestry.annotations.Inject;
 import org.apache.tapestry.annotations.Parameter;
-import org.apache.tapestry.internal.bindings.AbstractBinding;
 import org.apache.tapestry.internal.services.FormParameterLookup;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.services.TranslatorDefaultSource;
@@ -40,7 +39,7 @@
  */
 public abstract class AbstractTextField extends AbstractField
 {
-    @Parameter(required = true)
+    @Parameter(required = true, principal = true)
     private Object _value;
 
     @Parameter
@@ -65,25 +64,17 @@
     @Inject
     private Locale _locale;
 
-    final Binding defaultTranslate()
+    final Translator defaultTranslate()
     {
-        // Have to do this a bit the hard way: defer getting the translator until first needed,
-        // since we won't know the bound type of the value parameter until after
-        // containingPageDidLoad(). This is because fields are handled in alphabetical order, and
-        // _translate is ordered before _validate.
-
-        return new AbstractBinding()
-        {
-            private Translator _translator;
-
-            public Object get()
-            {
-                if (_translator == null)
-                    _translator = _translatorDefaultSource.find(_resources.getBoundType("value"));
-
-                return _translator;
-            }
-        };
+        // Because the value parameter is a principal parameter, we know that it will be bound (even
+        // via its default parameter) by the time this method is invoked.
+
+        Class type = _resources.getBoundType("value");
+
+        if (type == null)
+            return null;
+
+        return _translatorDefaultSource.find(type);
     }
 
     /**

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java Thu Feb  1 10:30:09 2007
@@ -183,7 +183,7 @@
 
         // Use the property name, not the field id, when locating
         // validation message overrides.
-        Messages overrideMessages = _resources.getContainerResources().getMessages();
+        Messages overrideMessages = _resources.getContainerMessages();
 
         for (String constraint : _validationConstraintGenerator
                 .buildConstraints(_propertyEditModel))
@@ -244,7 +244,7 @@
     public SelectModel getSelectModelForProperty()
     {
         return new EnumSelectModel(_propertyEditModel.getPropertyType(), _resources
-                .getContainerResources().getMessages());
+                .getContainerMessages());
     }
 
     public Form getForm()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Form.java Thu Feb  1 10:30:09 2007
@@ -209,7 +209,7 @@
 
         _resources.renderInformalParameters(writer);
 
-        _div = writer.element("div", "style", "t-invisible");
+        _div = writer.element("div", "class", "t-invisible");
 
         for (String parameterName : link.getParameterNames())
         {

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Label.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Label.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Label.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Label.java Thu Feb  1 10:30:09 2007
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.corelib.components;
 
+import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.Field;
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.ValidationDecorator;
@@ -22,14 +23,16 @@
 import org.apache.tapestry.annotations.BeginRender;
 import org.apache.tapestry.annotations.ComponentClass;
 import org.apache.tapestry.annotations.Environmental;
+import org.apache.tapestry.annotations.Inject;
 import org.apache.tapestry.annotations.Parameter;
-import org.apache.tapestry.corelib.mixins.RenderInformals;
+import org.apache.tapestry.annotations.SupportsInformalParameters;
 import org.apache.tapestry.dom.Element;
 import org.apache.tapestry.services.Heartbeat;
 
 /** Generates a &lt;label&gt; element for a particular field. */
 @ComponentClass
-public class Label extends RenderInformals
+@SupportsInformalParameters
+public class Label
 {
     /**
      * The for parameter is used to identify the {@link Field} linked to this label (it is named
@@ -44,6 +47,9 @@
     @Environmental
     private ValidationDecorator _decorator;
 
+    @Inject
+    private ComponentResources _resources;
+
     @BeginRender
     void begin(MarkupWriter writer)
     {
@@ -51,10 +57,13 @@
 
         final Element element = writer.element("label");
 
-        // Uh oh! Referenching a private field (that happens to get instrumented up the wazoo) from
+        _resources.renderInformalParameters(writer);
+
+        // Uh oh! Referencing a private field (that happens to get instrumented up the wazoo) from
         // a inner class causes a java.lang.Verify error (Unable to pop operand off an empty stack).
         // Perhaps this is a Javassist error? Shouldn't the inner class be going through a synthetic
-        // accessor method of some kind?
+        // accessor method of some kind? Resolved by assigning to a local variable and referencing
+        // that. Layers on layers, oh my!
 
         final ValidationDecorator decorator = _decorator;
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Select.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Select.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Select.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Select.java Thu Feb  1 10:30:09 2007
@@ -18,17 +18,21 @@
 import java.util.Map;
 
 import org.apache.tapestry.Binding;
+import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.EnumSelectModel;
+import org.apache.tapestry.EnumValueEncoder;
 import org.apache.tapestry.FieldValidator;
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.OptionGroupModel;
 import org.apache.tapestry.OptionModel;
+import org.apache.tapestry.SelectModel;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.ValidationTracker;
 import org.apache.tapestry.ValueEncoder;
-import org.apache.tapestry.SelectModel;
 import org.apache.tapestry.annotations.AfterRender;
 import org.apache.tapestry.annotations.BeforeRenderTemplate;
 import org.apache.tapestry.annotations.Environmental;
+import org.apache.tapestry.annotations.Inject;
 import org.apache.tapestry.annotations.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
 import org.apache.tapestry.internal.services.FormParameterLookup;
@@ -39,7 +43,7 @@
  */
 public final class Select extends AbstractField
 {
-    @Parameter(required = true)
+    @Parameter(required = true, principal = true)
     private Object _value;
 
     /**
@@ -75,9 +79,40 @@
     @Environmental
     private ValidationTracker _tracker;
 
+    @Inject
+    private ComponentResources _resources;
+
     Binding defaultValue()
     {
         return createDefaultParameterBinding("value");
+    }
+
+    @SuppressWarnings("unchecked")
+    ValueEncoder defaultEncoder()
+    {
+        Class valueType = _resources.getBoundType("value");
+
+        if (valueType == null)
+            return null;
+
+        if (Enum.class.isAssignableFrom(valueType))
+            return new EnumValueEncoder(valueType);
+
+        return null;
+    }
+
+    @SuppressWarnings("unchecked")
+    SelectModel defaultModel()
+    {
+        Class valueType = _resources.getBoundType("value");
+
+        if (valueType == null)
+            return null;
+
+        if (Enum.class.isAssignableFrom(valueType))
+            return new EnumSelectModel(valueType, _resources.getContainerMessages());
+
+        return null;
     }
 
     void beginRender(MarkupWriter writer)

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalComponentResourcesCommon.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalComponentResourcesCommon.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalComponentResourcesCommon.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/InternalComponentResourcesCommon.java Thu Feb  1 10:30:09 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.
@@ -48,9 +48,8 @@
     /**
      * Used during construction of the page to identify the binding for a particular parameter.
      * <p>
-     * TODO: Would prefer to move this to a sub-interface, say "MutableInternalComponentResources".
      */
-    void addParameter(String parameterName, Binding binding);
+    void bindParameter(String parameterName, Binding binding);
 
     /**
      * Returns the mixin instance for the fully qualfied mixin class name.

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/parser/StartComponentToken.java Thu Feb  1 10:30:09 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.
@@ -99,7 +99,7 @@
         add(builder, "type", _type);
         add(builder, "mixins", _mixins);
 
-        builder.insert(0, "STartComponentToken[");
+        builder.insert(0, "StartComponentToken[");
         builder.append("]");
 
         return builder.toString();

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/FieldValidatorSourceImpl.java Thu Feb  1 10:30:09 2007
@@ -59,12 +59,10 @@
         String overrideId = componentResources.getId();
         Locale locale = componentResources.getLocale();
 
-        ComponentResources containerResources = componentResources.getContainerResources();
-
         // So, if you use a TextField on your EditUser page, we want to search the messages
         // of the EditUser page (the container), not the TextField (which will always be the same).
 
-        Messages overrideMessages = containerResources.getMessages();
+        Messages overrideMessages = componentResources.getContainerMessages();
 
         return createValidator(
                 field,

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java Thu Feb  1 10:30:09 2007
@@ -53,6 +53,7 @@
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
 import org.apache.tapestry.model.ComponentModel;
 import org.apache.tapestry.runtime.Component;
+import org.apache.tapestry.services.FieldFilter;
 import org.apache.tapestry.services.MethodFilter;
 import org.apache.tapestry.services.MethodSignature;
 import org.apache.tapestry.services.TransformUtils;
@@ -783,74 +784,63 @@
         return true;
     }
 
-    public List<String> findFieldsWithAnnotation(Class<? extends Annotation> annotationClass)
+    public List<String> findFieldsWithAnnotation(final Class<? extends Annotation> annotationClass)
     {
-        failIfFrozen();
-
-        List<String> result = newList();
-
-        for (CtField field : _ctClass.getDeclaredFields())
+        FieldFilter filter = new FieldFilter()
         {
-            if (!isInstanceField(field))
-                continue;
-
-            String fieldName = field.getName();
-
-            if (_claimedFields.containsKey(fieldName))
-                continue;
-
-            List<Annotation> annotations = findFieldAnnotations(fieldName);
-
-            // Check to see if any of the annotations are the right type, if
-            // so, add the field name to the result.
-
-            for (Object annotation : annotations)
+            public boolean accept(String fieldName, String fieldType)
             {
-                if (annotationClass.isInstance(annotation))
-                {
-                    result.add(fieldName);
-                    break;
-                }
+                return getFieldAnnotation(fieldName, annotationClass) != null;
             }
-        }
+        };
 
-        Collections.sort(result);
-
-        return result;
+        return findFields(filter);
     }
 
-    public List<String> findFieldsOfType(String type)
+    public List<String> findFields(FieldFilter filter)
     {
         failIfFrozen();
 
         List<String> result = newList();
 
-        for (CtField field : _ctClass.getDeclaredFields())
+        try
         {
-            if (!isInstanceField(field))
-                continue;
+            for (CtField field : _ctClass.getDeclaredFields())
+            {
+                if (!isInstanceField(field))
+                    continue;
 
-            String fieldName = field.getName();
+                String fieldName = field.getName();
 
-            try
-            {
-                if (!field.getType().getName().equals(type))
+                if (_claimedFields.containsKey(fieldName))
                     continue;
-            }
-            catch (NotFoundException ex)
-            {
-                throw new RuntimeException(ex);
-            }
 
-            if (_claimedFields.containsKey(fieldName))
-                continue;
+                if (filter.accept(fieldName, field.getType().getName()))
+                    result.add(fieldName);
 
-            result.add(fieldName);
+            }
+        }
+        catch (NotFoundException ex)
+        {
+            throw new RuntimeException(ex);
         }
 
         Collections.sort(result);
 
         return result;
+    }
+
+    public List<String> findFieldsOfType(final String type)
+    {
+        FieldFilter filter = new FieldFilter()
+        {
+            public boolean accept(String fieldName, String fieldType)
+            {
+                return type.equals(fieldType);
+            }
+        };
+
+        return findFields(filter);
     }
 
     public List<MethodSignature> findMethodsWithAnnotation(

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=502308&r1=502307&r2=502308
==============================================================================
--- 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 Thu Feb  1 10:30:09 2007
@@ -112,8 +112,7 @@
         _persistentFieldManager = persistentFieldManager;
     }
 
-    // This is for bindings from the template.
-    private void addBindingToComponent(ComponentPageElement component, AttributeToken token)
+    private void bindParameterFromTemplate(ComponentPageElement component, AttributeToken token)
     {
         String name = token.getName();
         ComponentResources resources = component.getComponentResources();
@@ -140,7 +139,7 @@
                 token.getValue(),
                 token.getLocation());
 
-        component.addParameter(name, binding);
+        component.bindParameter(name, binding);
     }
 
     // As element, components, parameters or blocks are started, they push an element onto this
@@ -163,7 +162,7 @@
         }
     }
 
-    private void addParametersFromModel(EmbeddedComponentModel model,
+    private void bindParametersFromModel(EmbeddedComponentModel model,
             ComponentPageElement loadingComponent, ComponentPageElement component)
     {
         for (String name : model.getParameterNames())
@@ -186,27 +185,27 @@
                     value,
                     null);
 
-            component.addParameter(name, binding);
+            component.bindParameter(name, binding);
         }
     }
 
     /**
-     * Determines the default binding prefix for a particular parameters.
+     * Determines the default binding prefix for a particular parameter.
      * 
      * @param component
      *            the component which will have a parameter bound
      * @param parameterName
      *            the name of the parameter
-     * @param metaDefaultBindingPrefix
+     * @param informalParameterBindingPrefix
      *            the default to use for informal parameters
      * @return the binding prefix
      */
     private String determineDefaultBindingPrefix(ComponentPageElement component,
-            String parameterName, String metaDefaultBindingPrefix)
+            String parameterName, String informalParameterBindingPrefix)
     {
         String defaultBindingPrefix = component.getDefaultBindingPrefix(parameterName);
 
-        return defaultBindingPrefix != null ? defaultBindingPrefix : metaDefaultBindingPrefix;
+        return defaultBindingPrefix != null ? defaultBindingPrefix : informalParameterBindingPrefix;
     }
 
     private void addRenderBodyElement()
@@ -230,7 +229,7 @@
         {
             ComponentPageElement activeElement = _activeElementStack.peek();
 
-            addBindingToComponent(activeElement, token);
+            bindParameterFromTemplate(activeElement, token);
             return;
         }
 
@@ -462,7 +461,7 @@
 
         // TODO: Check that the t:parameter doesn't appear outside of an embedded component.
 
-        _activeElementStack.peek().addParameter(name, binding);
+        _activeElementStack.peek().bindParameter(name, binding);
 
         setupBlock(block);
     }
@@ -557,7 +556,7 @@
         addMixinsToComponent(newComponent, embeddedModel, token.getMixins());
 
         if (embeddedModel != null)
-            addParametersFromModel(embeddedModel, _loadingElement, newComponent);
+            bindParametersFromModel(embeddedModel, _loadingElement, newComponent);
 
         addToBody(newComponent);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java Thu Feb  1 10:30:09 2007
@@ -19,12 +19,15 @@
 
 import org.apache.tapestry.Binding;
 import org.apache.tapestry.annotations.Parameter;
+import org.apache.tapestry.internal.InternalComponentResources;
+import org.apache.tapestry.internal.bindings.LiteralBinding;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
 import org.apache.tapestry.ioc.util.BodyBuilder;
 import org.apache.tapestry.model.MutableComponentModel;
 import org.apache.tapestry.services.BindingSource;
 import org.apache.tapestry.services.ClassTransformation;
 import org.apache.tapestry.services.ComponentClassTransformWorker;
+import org.apache.tapestry.services.FieldFilter;
 import org.apache.tapestry.services.MethodFilter;
 import org.apache.tapestry.services.MethodSignature;
 import org.apache.tapestry.services.TransformConstants;
@@ -36,6 +39,8 @@
  */
 public class ParameterWorker implements ComponentClassTransformWorker
 {
+    private static final String BIND_METHOD_NAME = ParameterWorker.class.getName() + ".bind";
+
     private final BindingSource _bindingSource;
 
     public ParameterWorker(BindingSource bindingSource)
@@ -43,10 +48,33 @@
         _bindingSource = bindingSource;
     }
 
-    public void transform(ClassTransformation transformation, MutableComponentModel model)
+    public void transform(final ClassTransformation transformation, MutableComponentModel model)
     {
+        FieldFilter filter = new FieldFilter()
+        {
+            public boolean accept(String fieldName, String fieldType)
+            {
+                Parameter annotation = transformation
+                        .getFieldAnnotation(fieldName, Parameter.class);
+
+                return annotation != null && annotation.principal();
+            }
+        };
+
+        List<String> principleFieldNames = transformation.findFields(filter);
+
+        convertFieldsIntoParameters(transformation, model, principleFieldNames);
+
+        // Now convert the rest.
+
         List<String> fieldNames = transformation.findFieldsWithAnnotation(Parameter.class);
 
+        convertFieldsIntoParameters(transformation, model, fieldNames);
+    }
+
+    private void convertFieldsIntoParameters(ClassTransformation transformation,
+            MutableComponentModel model, List<String> fieldNames)
+    {
         for (String name : fieldNames)
             convertFieldIntoParameter(name, transformation, model);
     }
@@ -174,7 +202,7 @@
                     _bindingSource);
 
             builder.addln(
-                    "  %s.addParameter(\"%s\", %s.newBinding(\"default %2$s\", %1$s, \"%s\"));",
+                    "  %s.bindParameter(\"%s\", %s.newBinding(\"default %2$s\", %1$s, \"%s\"));",
                     resourcesFieldName,
                     parameterName,
                     bindingFactoryFieldName,
@@ -194,24 +222,25 @@
             public boolean accept(MethodSignature signature)
             {
                 return signature.getParameterTypes().length == 0
-                        && signature.getMethodName().equals(methodName)
-                        && signature.getReturnType().equals(Binding.class.getName());
+                        && signature.getMethodName().equals(methodName);
             }
         };
 
         // This will match exactly 0 or 1 methods, and if it matches, we know the name
         // of the method.
 
-        if (!transformation.findMethods(filter).isEmpty())
-        {
-            builder.addln("if (! %s.isBound(\"%s\"))", resourcesFieldName, parameterName);
+        List<MethodSignature> signatures = transformation.findMethods(filter);
 
-            builder.addln(
-                    "  %s.addParameter(\"%s\", %s());",
-                    resourcesFieldName,
-                    parameterName,
-                    methodName);
-        }
+        if (signatures.isEmpty())
+            return;
+
+        builder.addln("if (! %s.isBound(\"%s\"))", resourcesFieldName, parameterName);
+        builder.addln(
+                "  %s(\"%s\", %s, %s());",
+                BIND_METHOD_NAME,
+                parameterName,
+                resourcesFieldName,
+                methodName);
     }
 
     private void addWriterMethod(String fieldName, String cachedFieldName, boolean cache,
@@ -321,5 +350,22 @@
             return annotatedName;
 
         return InternalUtils.stripMemberPrefix(fieldName);
+    }
+
+    public static void bind(String parameterName, InternalComponentResources resources, Object value)
+    {
+        if (value == null)
+            return;
+
+        if (value instanceof Binding)
+        {
+            Binding binding = (Binding) value;
+
+            resources.bindParameter(parameterName, binding);
+            return;
+        }
+
+        resources.bindParameter(parameterName, new LiteralBinding("default " + parameterName,
+                value, null));
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/ComponentPageElementImpl.java Thu Feb  1 10:30:09 2007
@@ -625,7 +625,7 @@
         _components.add(resources.getComponent());
     }
 
-    public void addParameter(String parameterName, Binding binding)
+    public void bindParameter(String parameterName, Binding binding)
     {
         // Maybe should use colon here? Depends on what works best in the template,
         // don't want to lock this out as just
@@ -646,7 +646,7 @@
 
             String simpleName = parameterName.substring(dotx + 1);
 
-            mixinResources.addParameter(simpleName, binding);
+            mixinResources.bindParameter(simpleName, binding);
             return;
         }
 
@@ -656,7 +656,7 @@
 
         if (_coreResources.getComponentModel().getParameterModel(parameterName) != null)
         {
-            _coreResources.addParameter(parameterName, binding);
+            _coreResources.bindParameter(parameterName, binding);
             return;
         }
 
@@ -665,7 +665,7 @@
             InternalComponentResources resources = _mixinsByShortName.get(mixinName);
             if (resources.getComponentModel().getParameterModel(parameterName) != null)
             {
-                resources.addParameter(parameterName, binding);
+                resources.bindParameter(parameterName, binding);
                 return;
             }
 
@@ -684,7 +684,7 @@
         // that will likely change.
 
         if (informalParameterResources != null)
-            informalParameterResources.addParameter(parameterName, binding);
+            informalParameterResources.bindParameter(parameterName, binding);
     }
 
     public void addToBody(PageElement element)

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java Thu Feb  1 10:30:09 2007
@@ -166,7 +166,7 @@
         _element.persistFieldChange(this, fieldName, newValue);
     }
 
-    public void addParameter(String parameterName, Binding binding)
+    public void bindParameter(String parameterName, Binding binding)
     {
         if (_bindings == null)
             _bindings = newMap();
@@ -201,7 +201,7 @@
     {
         Binding b = getBinding(parameterName);
 
-        return b != null ? b.getBindingType() : Object.class;
+        return b != null ? b.getBindingType() : null;
     }
 
     @SuppressWarnings("unchecked")
@@ -209,7 +209,6 @@
     {
         Binding b = getBinding(parameterName);
 
-    
         Class bindingType = b.getBindingType();
 
         try
@@ -266,6 +265,11 @@
     public ComponentResources getContainerResources()
     {
         return _containerResources;
+    }
+
+    public Messages getContainerMessages()
+    {
+        return _containerResources != null ? _containerResources.getMessages() : null;
     }
 
     public Locale getLocale()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ClassTransformation.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ClassTransformation.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ClassTransformation.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/ClassTransformation.java Thu Feb  1 10:30:09 2007
@@ -88,6 +88,15 @@
     List<MethodSignature> findMethods(MethodFilter filter);
 
     /**
+     * Finds all unclaimed fields matched by the provided filter.
+     * 
+     * @param filter
+     *            passed each field name and field type
+     * @return the names of all matched fields, in ascending order
+     */
+    List<String> findFields(FieldFilter filter);
+
+    /**
      * Finds an annotation for the class itself, including any annotations inherited from parent
      * classes.
      * 

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldFilter.java?view=auto&rev=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldFilter.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldFilter.java Thu Feb  1 10:30:09 2007
@@ -0,0 +1,9 @@
+package org.apache.tapestry.services;
+
+/**
+ * Used by {@link ClassTransformation#findFields(FieldFilter)} to identify which fields to keep.
+ */
+public interface FieldFilter
+{
+    boolean accept(String fieldName, String fieldType);
+}

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=502308&r1=502307&r2=502308
==============================================================================
--- 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 Thu Feb  1 10:30:09 2007
@@ -705,6 +705,12 @@
         expect(resources.getContainerResources()).andReturn(containerResources).atLeastOnce();
     }
 
+    protected final void train_getContainerMessages(ComponentResources resources,
+            Messages containerMessages)
+    {
+        expect(resources.getContainerMessages()).andReturn(containerMessages).atLeastOnce();
+    }
+
     protected final void train_getId(ComponentResources resources, String id)
     {
         expect(resources.getId()).andReturn(id).atLeastOnce();
@@ -773,7 +779,8 @@
         expect(messages.contains(isA(String.class))).andStubReturn(contained);
     }
 
-    protected final <T extends Annotation> void train_getAnnotation(PropertyConduit conduit, Class<T> annotationClass, T annotation)
+    protected final <T extends Annotation> void train_getAnnotation(PropertyConduit conduit,
+            Class<T> annotationClass, T annotation)
     {
         expect(conduit.getAnnotation(annotationClass)).andReturn(annotation).atLeastOnce();
     }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/guide/parameters.apt Thu Feb  1 10:30:09 2007
@@ -291,8 +291,11 @@
 Computed Parameter Binding Defaults
 
   In <rare> cases, you may want to compute the binding to be used as a parameter default. In this case, you will provide
-  a <default binding method>, a method that takes no parameters and returns a 
-  {{{../apidocs/org/apache/tapestry/Binding.html}Binding}} instance.  The method name is "default" plus the capitalized name
+  a <default binding method>, a method that takes no parameters.  The returned value is used to bind the parameter.  The return value may
+  be a
+  {{{../apidocs/org/apache/tapestry/Binding.html}Binding}} instance, or it may be a simple value (which is more often the case).  
+  
+  The method name is "default" plus the capitalized name
   of the parameter.
   
   Using this approach, the previous example may be rewritten as:
@@ -310,7 +313,7 @@
   @Inject("infrastructure:BindingSource")
   private BindingSource _bindingSource;
   
-  Binding defaultValue()
+  Binding defaultMessage()
   {
     return _bindingSource.newBinding("default value", _resources, "defaultMessage");
   }
@@ -320,6 +323,31 @@
     return String.format("Maximum field length is %d.", _maxLength);
   }
 +---+  
+  
+  In this example, a property expression, "defaultMessage", is used to access the message dynamically.
+  
+  Alternately, the previous example may be written even more succinctly as:
+  
++----+
+  @Parameter
+  private String _message;
+  
+  @Parameter(required=true)
+  private int _maxLength;
+  
+  @Inject
+  private ComponentResources _resources;
+  
+  @Inject("infrastructure:BindingSource")
+  private BindingSource _bindingSource;
+  
+  String defaultMessage()
+  {
+    return String.format("Maximum field length is %d.", _maxLength);
+  }  
++---+  
+  
+  This form is more like using the "literal:" binding prefix, except that the literal value is computed by the defaultMessage() method.
   
   Obviously, this is a lot more work than simply specifying a default value as part of the Parameter annotation. In the few
   real cases where this is approach is used, the default binding method will usually deduce a proper binding, typically in terms of

Modified: tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/site/apt/index.apt Thu Feb  1 10:30:09 2007
@@ -38,8 +38,11 @@
   Progress on Tapestry 5 is really taking off. This space lists some cool new features that have been added
   recently.
   
+  * BeanEditForm component that creates a form and related controls to edit the properties of any JavaBean, automatically.
+    Inspired by {{{http://www.trailsframework.org/}Trails}} and {{{http://beanform.sourceforge.net/}BeanForm}} (both for Tapestry 4).
+  
   * Case insensitve URLs.  Tapestry no longer cares about the case of the page names and commponent ids it puts
-    into URLs, and they are now generated in all lower-case for that clean "Web 2.0" loop.  And they're 
+    into URLs, and they are now generated in all lower-case for that clean "Web 2.0" look.  And they're 
     shorter, too!
   
   * Initial support for {{{guide/appstate.html}application state objects}}.

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/SimpleForm.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/SimpleForm.html?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/SimpleForm.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/SimpleForm.html Thu Feb  1 10:30:09 2007
@@ -5,26 +5,33 @@
 
     <form t:type="Form">
         <input t:type="Checkbox" t:id="disabled"/>
-        <label t:type="Label" for="disabled"/>
-        
-        <hr/>
-        
-        <label t:type="Label"  for="email">This isn't used</label>: <input
-            t:type="TextField" t:id="email" value="incident.email" size="50"  disabled="disabled"/>
-        <br/>
-        <label t:type="Label"  for="message"/>: <input t:type="TextArea" t:id="message" label="Incident Message"
-            value="incident.message" cols="50" rows="10" disabled="disabled"> You can put text here, but it isn't used. </input>
+        <label id="l1" t:type="Label" for="disabled"/>
         <br/>
-        <label t:type="Label" for="operatingSystem"/>:
-        <select t:type="Select"  t:id="operatingSystem" value="incident.operatingSystem" model="message:os-values" disabled="disabled"/>
-        
         
-        <br/>
-        
-        <input t:type="Checkbox" t:id="urgent" value="incident.urgent" disabled="disabled"/>
-        <label t:type="Label" for="urgent"/>
-        <br/>
-        <input type="submit"/>
+        <div class="t-beaneditor">
+            
+            <label id="l2" t:type="Label" for="email">This isn't used</label>
+            <input t:type="TextField"
+                t:id="email" value="incident.email" size="50" disabled="disabled"/>
+            <br/>
+            <label id="l3" t:type="Label" for="message"/>
+            <input t:type="TextArea" t:id="message"
+                label="Incident Message" value="incident.message" cols="50" rows="10"
+                disabled="disabled"> You can put text here, but it isn't used. </input>
+            <br/>
+            <label id="l4" t:type="Label" for="operatingSystem"/>
+            <select t:type="Select"
+                t:id="operatingSystem" value="incident.operatingSystem" model="message:os-values"
+                disabled="disabled"/>
+            <br/>
+            <label id="l5" t:type="Label" for="department"/>
+            <select t:type="Select" t:id="department"
+                value="incident.department" disabled="disabled"/>
+            <br/>
+            <label id="l6" t:type="Label" for="urgent"/>
+            <input t:type="Checkbox" t:id="urgent" value="incident.urgent" disabled="disabled"/>
+            <br/>
+            <input type="submit"/></div>
     </form>
 
     <hr/>
@@ -35,7 +42,8 @@
         <li>email: [${incident.email}]</li>
         <li>message: [${incident.message}]</li>
         <li>OS: [${incident.operatingSystem}]</li>
-        <li>urgent: [${incident.urgent}]</li>
+        <li>urgent: [${incident.urgent}]</li>
+        <li>department: [${incident.department}]</li>
     </ul>
 
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Thu Feb  1 10:30:09 2007
@@ -475,20 +475,23 @@
 
         clickAndWait("link=SimpleForm");
 
-        assertText("//label[1]", "Disabled");
-        assertText("//label[2]", "Email");
-        assertText("//label[3]", "Incident Message");
-        assertText("//label[4]", "Operating System");
-        assertText("//label[5]", "Urgent Processing Requested");
+        assertText("//label[@id='l1']", "Disabled");
+        assertText("//label[@id='l2']", "Email");
+        assertText("//label[@id='l3']", "Incident Message");
+        assertText("//label[@id='l4']", "Operating System");
+        assertText("//label[@id='l5']", "Department");
+        assertText("//label[@id='l6']", "Urgent Processing Requested");
 
         assertValue("email", "");
         assertValue("message", "");
         assertValue("operatingSystem", "osx");
+        assertValue("department", "ACCOUNTING");
         assertValue("urgent", "on");
 
         _selenium.type("email", "foo@bar.baz");
         _selenium.type("message", "Message for you, sir!");
         _selenium.select("operatingSystem", "Windows NT");
+        _selenium.select("department", "R&D");
         _selenium.click("urgent");
 
         clickAndWait("//input[@type='submit']");
@@ -499,10 +502,12 @@
 
         // Tried to use "email:" and "exact:email:" but Selenium 0.8.1 doesn't seem to accept that.
 
-        assertTextPresent("[foo@bar.baz]");
-        assertTextPresent("[Message for you, sir!]");
-        assertTextPresent("[false]");
-        assertTextPresent("[winnt]");
+        assertTextPresent(
+                "[foo@bar.baz]",
+                "[Message for you, sir!]",
+                "[false]",
+                "[winnt]",
+                "[RESEARCH_AND_DESIGN]");
 
         // Haven't figured out how to get selenium to check that fields are disabled.
     }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Department.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Department.java?view=auto&rev=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Department.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Department.java Thu Feb  1 10:30:09 2007
@@ -0,0 +1,6 @@
+package org.apache.tapestry.integration.app1.data;
+
+public enum Department {
+
+    ACCOUNTING, RESEARCH_AND_DESIGN, IT, SALES_AND_MARKETING
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/IncidentData.java Thu Feb  1 10:30:09 2007
@@ -18,7 +18,7 @@
 
 public class IncidentData implements Serializable
 {
-    private static final long serialVersionUID = 7512595251925899186L;
+    private static final long serialVersionUID = -321606932140181054L;
 
     private String _email;
 
@@ -30,6 +30,8 @@
 
     private int _hours;
 
+    private Department _department;
+
     public String getEmail()
     {
         return _email;
@@ -78,6 +80,16 @@
     public void setHours(int hours)
     {
         _hours = hours;
+    }
+
+    public Department getDepartment()
+    {
+        return _department;
+    }
+
+    public void setDepartment(Department department)
+    {
+        _department = department;
     }
 
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorSourceImplTest.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorSourceImplTest.java Thu Feb  1 10:30:09 2007
@@ -50,15 +50,13 @@
         TypeCoercer coercer = newTypeCoercer();
         FieldComponent field = newFieldComponent();
         ComponentResources resources = newComponentResources();
-        ComponentResources containerResources = newComponentResources();
         Messages containerMessages = newMessages();
         Map<String, Validator> map = newMap();
 
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
         train_getLocale(resources, Locale.ENGLISH);
-        train_getContainerResources(resources, containerResources);
-        train_getMessages(containerResources, containerMessages);
+        train_getContainerMessages(resources, containerMessages);
 
         map.put("alpha", validator);
         map.put("beta", validator);
@@ -94,8 +92,7 @@
         MessageFormatter formatter = newMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = newComponentResources();
-        ComponentResources containerResources = newComponentResources();
-        Messages componentMessages = newMessages();
+        Messages containerMessages = newMessages();
 
         Map<String, Validator> map = singletonMap("required", validator);
 
@@ -104,9 +101,8 @@
         train_getComponentResources(field, resources);
 
         train_getId(resources, "fred");
-        train_getContainerResources(resources, containerResources);
-        train_getMessages(containerResources, componentMessages);
-        train_contains(componentMessages, "fred-required", false);
+        train_getContainerMessages(resources, containerMessages);
+        train_contains(containerMessages, "fred-required", false);
 
         train_getLocale(resources, Locale.FRENCH);
 
@@ -141,8 +137,7 @@
         MessageFormatter formatter = newMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = newComponentResources();
-        ComponentResources containerResources = newComponentResources();
-        Messages componentMessages = newMessages();
+        Messages containerMessages = newMessages();
 
         Map<String, Validator> map = singletonMap("required", validator);
 
@@ -151,11 +146,10 @@
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
         train_getLocale(resources, Locale.ENGLISH);
-        train_getContainerResources(resources, containerResources);
-        train_getMessages(containerResources, componentMessages);
-        train_contains(componentMessages, "fred-required", true);
+        train_getContainerMessages(resources, containerMessages);
+        train_contains(containerMessages, "fred-required", true);
 
-        train_getMessageFormatter(componentMessages, "fred-required", formatter);
+        train_getMessageFormatter(containerMessages, "fred-required", formatter);
 
         train_invokeIfBlank(validator, false);
         train_getValueType(validator, Object.class);
@@ -184,8 +178,7 @@
         MessageFormatter formatter = newMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = newComponentResources();
-        ComponentResources containerResources = newComponentResources();
-        Messages componentMessages = newMessages();
+        Messages containerMessages = newMessages();
 
         Map<String, Validator> map = singletonMap("required", validator);
 
@@ -193,9 +186,8 @@
 
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
-        train_getContainerResources(resources, containerResources);
-        train_getMessages(containerResources, componentMessages);
-        train_contains(componentMessages, "fred-required", false);
+        train_getContainerMessages(resources, containerMessages);
+        train_contains(containerMessages, "fred-required", false);
 
         train_getLocale(resources, Locale.FRENCH);
 
@@ -204,7 +196,7 @@
         train_getMessageKey(validator, "key");
         train_getMessageFormatter(messages, "key", formatter);
 
-        train_invokeIfBlank(validator,false);
+        train_invokeIfBlank(validator, false);
         train_getValueType(validator, Object.class);
         validator.validate(field, null, formatter, inputValue);
 
@@ -233,8 +225,7 @@
         MessageFormatter minLengthFormatter = newMessageFormatter();
         Object inputValue = "input value";
         ComponentResources resources = newComponentResources();
-        ComponentResources containerResources = newComponentResources();
-        Messages componentMessages = newMessages();
+        Messages containerMessages = newMessages();
         Integer fifteen = 15;
 
         Map<String, Validator> map = newMap();
@@ -247,9 +238,8 @@
 
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
-        train_getContainerResources(resources, containerResources);
-        train_getMessages(containerResources, componentMessages);
-        train_contains(componentMessages, "fred-required", false);
+        train_getContainerMessages(resources, containerMessages);
+        train_contains(containerMessages, "fred-required", false);
 
         train_getLocale(resources, Locale.FRENCH);
 
@@ -258,7 +248,7 @@
         train_getMessageKey(required, "required");
         train_getMessageFormatter(messages, "required", requiredFormatter);
 
-        train_contains(componentMessages, "fred-minLength", false);
+        train_contains(containerMessages, "fred-minLength", false);
 
         train_getMessageKey(minLength, "min-length");
         train_getMessageFormatter(messages, "min-length", minLengthFormatter);
@@ -296,8 +286,7 @@
         MessageFormatter formatter = newMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = newComponentResources();
-        ComponentResources containerResources = newComponentResources();
-        Messages componentMessages = newMessages();
+        Messages containerMessages = newMessages();
         Integer five = 5;
 
         Map<String, Validator> map = singletonMap("minLength", validator);
@@ -308,9 +297,8 @@
 
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
-        train_getContainerResources(resources, containerResources);
-        train_getMessages(containerResources, componentMessages);
-        train_contains(componentMessages, "fred-minLength", false);
+        train_getContainerMessages(resources, containerMessages);
+        train_contains(containerMessages, "fred-minLength", false);
 
         train_getLocale(resources, Locale.FRENCH);
 

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=502308&r1=502307&r2=502308
==============================================================================
--- 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 Thu Feb  1 10:30:09 2007
@@ -475,7 +475,7 @@
                 expect(source.newBinding("default value", resources, "literal:greeting"))
                         .andReturn(binding);
 
-                resources.addParameter("value", binding);
+                resources.bindParameter("value", binding);
 
                 train_isInvariant(resources, "value", true);
 
@@ -521,7 +521,7 @@
 
                 // How can this happen? Only if the generated code invokes defaultValue().
 
-                resources.addParameter("value", _binding);
+                resources.bindParameter("value", _binding);
 
                 train_isInvariant(resources, "value", true);
             };

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/ComponentPageElementImplTest.java Thu Feb  1 10:30:09 2007
@@ -121,7 +121,7 @@
         ComponentResources resources = cpe.getComponentResources();
         assertFalse(resources.isBound("fred"));
 
-        cpe.addParameter("barney", binding);
+        cpe.bindParameter("barney", binding);
 
         assertFalse(resources.isBound("fred"));
         assertTrue(resources.isBound("barney"));
@@ -183,7 +183,7 @@
 
         ComponentPageElementImpl cpe = new ComponentPageElementImpl(page, ins, coercer, null);
 
-        cpe.addParameter("barney", binding);
+        cpe.bindParameter("barney", binding);
 
         cpe.containingPageDidLoad();
 
@@ -293,7 +293,7 @@
 
         assertFalse(cpe.getComponentResources().isInvariant("fred"));
 
-        cpe.addParameter("barney", binding);
+        cpe.bindParameter("barney", binding);
 
         assertFalse(cpe.getComponentResources().isInvariant("fred"));
         assertTrue(cpe.getComponentResources().isInvariant("barney"));
@@ -326,7 +326,7 @@
 
         ComponentPageElement cpe = new ComponentPageElementImpl(page, ins, coercer, null);
 
-        cpe.addParameter("barney", binding);
+        cpe.bindParameter("barney", binding);
 
         assertSame(cpe.getComponentResources().readParameter("barney", Long.class), boundValue);
 
@@ -358,7 +358,7 @@
 
         ComponentPageElement cpe = new ComponentPageElementImpl(page, ins, coercer, null);
 
-        cpe.addParameter("barney", binding);
+        cpe.bindParameter("barney", binding);
 
         cpe.getComponentResources().writeParameter("barney", 23);
 
@@ -544,7 +544,7 @@
 
         try
         {
-            cpe.addParameter("Wilma.barney", binding);
+            cpe.bindParameter("Wilma.barney", binding);
             unreachable();
         }
         catch (TapestryException ex)

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImplTest.java?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImplTest.java Thu Feb  1 10:30:09 2007
@@ -70,7 +70,7 @@
         InternalComponentResources resources = new InternalComponentResourcesImpl(element, null,
                 ins, coercer, null);
 
-        resources.addParameter("fred", binding);
+        resources.bindParameter("fred", binding);
 
         resources.renderInformalParameters(writer);
 
@@ -105,7 +105,7 @@
         InternalComponentResources resources = new InternalComponentResourcesImpl(element, null,
                 ins, coercer, null);
 
-        resources.addParameter("fred", binding);
+        resources.bindParameter("fred", binding);
 
         resources.renderInformalParameters(writer);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.properties?view=diff&rev=502308&r1=502307&r2=502308
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/SimpleForm.properties Thu Feb  1 10:30:09 2007
@@ -19,4 +19,9 @@
   vista=Windows Vista, \
   os9=Mac OS 9, \
   osx=Mac OS X, \
-  linux=Linux
\ No newline at end of file
+  linux=Linux
+  
+# Correct some of the labels for the drop down list
+SALES_AND_MARKETING=Sales/Marketing
+RESEARCH_AND_DESIGN=R&D
+IT=IT
\ No newline at end of file



Mime
View raw message