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

svn commit: r502037 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/ main/java/org/apache/tapestry/beaneditor/ main/java/org/apache/tapestry/corelib/base/ main/java/org/apache/tapestry/corelib/components/ main/java/org/a...

Author: hlship
Date: Wed Jan 31 15:20:55 2007
New Revision: 502037

URL: http://svn.apache.org/viewvc?view=rev&rev=502037
Log:
Add implementions of ValueEncoder and SelectModel that work with Enum types.
Extend PropertyEditModel to contain an editorType property.
Set the initial editorType based on a service configuration.
Rename the BeanEditor component to BeanEditForm.
Extend BeanEditForm to provide a Select component for editting enum types.

Added:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.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/corelib/components/BeanEditForm.java
      - copied, changed from r501975, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html
      - copied, changed from r501975, tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.html
    tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.properties
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/EnumSelectModelTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/Stooge.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Sex.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/EnumBean.java
Removed:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.html
Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValueEncoder.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/beaneditor/PropertyEditModel.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/Select.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/BeanEditorModelImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyEditModelImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldValidatorSource.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/BeanEditorDemo.html
    tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.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/RegistrationData.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/TapestryUtilsTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImplTest.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java?view=auto&rev=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumSelectModel.java Wed Jan 31 15:20:55 2007
@@ -0,0 +1,91 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry;
+
+import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newList;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.apache.tapestry.internal.OptionModelImpl;
+import org.apache.tapestry.internal.TapestryUtils;
+import org.apache.tapestry.ioc.IOCUtilities;
+import org.apache.tapestry.ioc.Messages;
+import org.apache.tapestry.ioc.internal.util.Defense;
+
+/**
+ * A basic select model for a particular Enum type. The labels for each Enum are drawn from the Enum
+ * instance name and the provides message catalog:
+ * <ul>
+ * <li>As key <em>ClassName</em>-<em>name</em> if present. The class name excludes the
+ * package portion. Ex: "ElementType.LOCAL_VARIABLE"
+ * <li>As key <em>name</em> if present, i.e., "LOCAL_VARIABLE".
+ * <li>As a user-presentable version of the name, i.e., "Local Variable".
+ * </ul>
+ */
+public final class EnumSelectModel implements SelectModel, Serializable
+{
+    private static final long serialVersionUID = -3590412082766899684L;
+
+    private final List<OptionModel> _options = newList();;
+
+    public <T extends Enum> EnumSelectModel(Class<T> enumClass, Messages messages)
+    {
+        this(enumClass, messages, enumClass.getEnumConstants());
+    }
+
+    public <T extends Enum> EnumSelectModel(Class<T> enumClass, Messages messages, T[] values)
+    {
+        Defense.notNull(enumClass, "enumClass");
+        Defense.notNull(messages, "messages");
+
+        String prefix = IOCUtilities.toSimpleId(enumClass.getName());
+
+        for (T value : values)
+        {
+            String label = labelForValue(messages, prefix, value);
+
+            _options.add(new OptionModelImpl(label, false, value));
+        }
+    }
+
+    private String labelForValue(Messages messages, String prefix, Enum value)
+    {
+        String name = value.name();
+
+        String key = prefix + "." + name;
+
+        if (messages.contains(key))
+            return messages.get(key);
+
+        if (messages.contains(name))
+            return messages.get(name);
+
+        return TapestryUtils.toUserPresentable(name.toLowerCase());
+    }
+
+    /** Returns null. */
+    public List<OptionGroupModel> getOptionGroups()
+    {
+        return null;
+    }
+
+    /** Returns the option groupos created in the constructor. */
+    public List<OptionModel> getOptions()
+    {
+        return _options;
+    }
+
+}

Added: 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=auto&rev=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumValueEncoder.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/EnumValueEncoder.java Wed Jan 31 15:20:55 2007
@@ -0,0 +1,45 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry;
+
+import org.apache.tapestry.ioc.internal.util.Defense;
+
+/**
+ * A value encoder that can be used for aribrary Enum types. The enum name is stored as the client
+ * side value (the "primary key").
+ */
+public class EnumValueEncoder implements ValueEncoder<Enum>
+{
+    private final Class<Enum> _enumType;
+
+    public EnumValueEncoder(final Class<Enum> enumType)
+    {
+        Defense.notNull(enumType, "enumType");
+
+        _enumType = enumType;
+    }
+
+    public String toClient(Enum value)
+    {
+        return value.name();
+    }
+
+    @SuppressWarnings("unchecked")
+    public Enum toValue(String clientValue)
+    {
+        return Enum.valueOf(_enumType, clientValue);
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValueEncoder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValueEncoder.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValueEncoder.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/ValueEncoder.java Wed Jan 31 15:20:55 2007
@@ -39,9 +39,9 @@
      * Converts a client-side representation, provided by {@link #toClient(Object)}, back into a
      * server-side value.
      * 
-     * @param primaryKey
-     *            string representation of an entities primary key
+     * @param clientValue
+     *            string representation of the value's identity
      * @return the corresponding entity, or null if not found
      */
-    V toValue(String primaryKey);
+    V toValue(String clientValue);
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/beaneditor/PropertyEditModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/beaneditor/PropertyEditModel.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/beaneditor/PropertyEditModel.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/beaneditor/PropertyEditModel.java Wed Jan 31 15:20:55 2007
@@ -33,6 +33,20 @@
     Class getPropertyType();
 
     /**
+     * Returns a logical name for the type of UI needed to edit the property. This is initially
+     * determined from the property type.
+     */
+    String getEditorType();
+
+    /**
+     * Changes the editor type for the property.
+     * 
+     * @param editorType
+     * @return the property edit model, for further changes
+     */
+    PropertyEditModel editorType(String editorType);
+
+    /**
      * Returns an object used to read or update the property. For virtual properties (properties
      * that do not actually exist on the bean), the conduit may be null until one is provided via
      * {@link MutablePropertyEditModel#conduit(PropertyConduit)}.
@@ -44,7 +58,7 @@
      * 
      * @param propertyType
      *            the new property type for the property.
-     * @return the property's model, for further changes
+     * @return the property edit model, for further changes
      */
     PropertyEditModel propertyType(Class propertyType);
 
@@ -53,7 +67,7 @@
      * 
      * @param label
      *            new label for property
-     * @return the property's model, for further changes
+     * @return the property edit model, for further changes
      */
     PropertyEditModel label(String label);
 
@@ -68,7 +82,7 @@
      * 
      * @param conduit
      *            new conduit object (used to read or update the property value on an instance)
-     * @return the property's model, for further changes
+     * @return the property edit model, for further changes
      */
     PropertyEditModel conduit(PropertyConduit conduit);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/base/AbstractField.java Wed Jan 31 15:20:55 2007
@@ -205,7 +205,8 @@
     }
 
     /**
-     * Used by subclasses to create a default binding to a property of the container.
+     * Used by subclasses to create a default binding to a property of the container matching the
+     * component id.
      * 
      * @return a binding to the property, or null if the container does not have a corresponding
      *         property

Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java (from r501975, tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.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=502037&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java&r1=501975&p2=tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditor.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/corelib/components/BeanEditForm.java Wed Jan 31 15:20:55 2007
@@ -21,9 +21,13 @@
 
 import org.apache.tapestry.Block;
 import org.apache.tapestry.ComponentResources;
+import org.apache.tapestry.EnumSelectModel;
+import org.apache.tapestry.EnumValueEncoder;
 import org.apache.tapestry.Field;
 import org.apache.tapestry.FieldValidator;
+import org.apache.tapestry.SelectModel;
 import org.apache.tapestry.Translator;
+import org.apache.tapestry.ValueEncoder;
 import org.apache.tapestry.annotations.Component;
 import org.apache.tapestry.annotations.ComponentClass;
 import org.apache.tapestry.annotations.Inject;
@@ -52,7 +56,7 @@
  * @see BeanEditorModelSource
  */
 @ComponentClass
-public class BeanEditor
+public class BeanEditForm
 {
     /** The object to be editted by the BeanEditor. */
     @Parameter(required = true)
@@ -76,12 +80,24 @@
     @Inject
     private Block _text;
 
+    @Inject
+    private Block _enum;
+
+    @Component(parameters =
+    { "value=valueForProperty", "label=prop:propertyEditModel.label",
+            "encoder=valueEncoderForProperty", "model=selectModelForProperty",
+            "validate=prop:validateForProperty" })
+    private Select _select;
+
     @Component(parameters =
     { "value=valueForProperty", "label=prop:propertyEditModel.label",
             "translate=prop:translateForProperty", "validate=prop:validateForProperty" })
     private TextField _textField;
 
     @Inject
+    private Messages _messages;
+
+    @Inject
     private Locale _locale;
 
     @Parameter
@@ -104,10 +120,26 @@
     {
         _propertyEditModel = _model.get(propertyName);
 
-        // Shortly, we'll do a bit more work to set these two values.
+        _blockForProperty = null;
+        _fieldForProperty = null;
+
+        String editorType = _propertyEditModel.getEditorType();
+
+        if (editorType.equals("text"))
+        {
+            _blockForProperty = _text;
+            _fieldForProperty = _textField;
+            return;
+        }
+
+        if (editorType.equals("enum"))
+        {
+            _blockForProperty = _enum;
+            _fieldForProperty = _select;
+            return;
+        }
 
-        _blockForProperty = _text;
-        _fieldForProperty = _textField;
+        throw new IllegalArgumentException(_messages.format("no-editor", editorType, propertyName));
     }
 
     public String getPropertyName()
@@ -124,7 +156,7 @@
 
         if (_model == null)
         {
-            Class beanType = _object.getClass();
+            Class<? extends Object> beanType = _object.getClass();
 
             _model = _modelSource.create(beanType, _resources.getContainerResources());
         }
@@ -144,7 +176,6 @@
         // Use the property name, not the field id, when locating
         // validation message overrides.
         String overrideId = _propertyEditModel.getPropertyName();
-        // Pull override messages out of the BeanEditor's container
         Messages overrideMessages = _resources.getContainerResources().getMessages();
 
         for (String constraint : _validationConstraintGenerator
@@ -192,5 +223,20 @@
     public void setValueForProperty(Object value)
     {
         _propertyEditModel.getConduit().write(_object, value);
+    }
+
+    /** Provide a value encoder for an enum type. */
+    @SuppressWarnings("unchecked")
+    public ValueEncoder getValueEncoderForProperty()
+    {
+        return new EnumValueEncoder(_propertyEditModel.getPropertyType());
+    }
+
+    /** Provide a select mode for an enum type. */
+    @SuppressWarnings("unchecked")
+    public SelectModel getSelectModelForProperty()
+    {
+        return new EnumSelectModel(_propertyEditModel.getPropertyType(), _resources
+                .getContainerResources().getMessages());
     }
 }

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=502037&r1=502036&r2=502037
==============================================================================
--- 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 Wed Jan 31 15:20:55 2007
@@ -18,13 +18,17 @@
 import java.util.Map;
 
 import org.apache.tapestry.Binding;
+import org.apache.tapestry.FieldValidator;
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.OptionGroupModel;
 import org.apache.tapestry.OptionModel;
+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.Parameter;
 import org.apache.tapestry.corelib.base.AbstractField;
 import org.apache.tapestry.internal.services.FormParameterLookup;
@@ -64,6 +68,13 @@
     @Parameter(required = true)
     private SelectModel _model;
 
+    @Parameter(defaultPrefix = "validate")
+    @SuppressWarnings("unchecked")
+    private FieldValidator<Object> _validate = NOOP_VALIDATOR;
+
+    @Environmental
+    private ValidationTracker _tracker;
+
     Binding defaultValue()
     {
         return createDefaultParameterBinding("value");
@@ -161,7 +172,17 @@
 
         Object selectedValue = _encoder.toValue(primaryKey);
 
-        _value = selectedValue;
+        try
+        {
+            _validate.validate(selectedValue);
+
+            _value = selectedValue;
+        }
+        catch (ValidationException ex)
+        {
+            _tracker.recordError(this, ex.getMessage());
+            return;
+        }
     }
 
     // For testing.

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/TapestryUtils.java Wed Jan 31 15:20:55 2007
@@ -60,7 +60,8 @@
 
     /**
      * Capitalizes the string, and inserts a space before each upper case character (or sequence of
-     * upper case characters). Thus "userId" becomes "User Id", etc.
+     * upper case characters). Thus "userId" becomes "User Id", etc.  Also, converts underscore
+     * into space (and capitalizes the following word), thus "user_id" also becomes "User Id".
      */
     public static String toUserPresentable(String id)
     {
@@ -68,14 +69,24 @@
 
         char[] chars = id.toCharArray();
         boolean postSpace = true;
-
+        boolean upcaseNext = true;
+        
         for (int i = 0; i < chars.length; i++)
         {
             char ch = chars[i];
 
-            if (i == 0)
+            if (upcaseNext)
             {
                 builder.append(Character.toUpperCase(ch));
+                upcaseNext = false;
+                
+                continue;
+            }
+            
+            if (ch == '_')
+            {
+                builder.append(' ');
+                upcaseNext = true;
                 continue;
             }
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/BeanEditorModelImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/BeanEditorModelImpl.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/BeanEditorModelImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/BeanEditorModelImpl.java Wed Jan 31 15:20:55 2007
@@ -25,6 +25,7 @@
 import java.util.Map;
 
 import org.apache.tapestry.beaneditor.BeanEditorModel;
+import org.apache.tapestry.beaneditor.Order;
 import org.apache.tapestry.beaneditor.PropertyConduit;
 import org.apache.tapestry.beaneditor.PropertyEditModel;
 import org.apache.tapestry.internal.TapestryUtils;
@@ -72,6 +73,14 @@
 
         if (adapter != null)
             propertyModel.propertyType(adapter.getType());
+
+        if (conduit != null)
+        {
+            Order annotation = conduit.getAnnotation(Order.class);
+
+            if (annotation != null)
+                propertyModel.order(annotation.value());
+        }
 
         _properties.put(propertyName, propertyModel);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyEditModelImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyEditModelImpl.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyEditModelImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyEditModelImpl.java Wed Jan 31 15:20:55 2007
@@ -35,6 +35,8 @@
 
     private Class _propertyType = Object.class;
 
+    private String _editorType;
+
     public PropertyEditModelImpl(BeanEditorModel model, final String name)
     {
         _model = model;
@@ -110,5 +112,17 @@
     public BeanEditorModel model()
     {
         return _model;
+    }
+
+    public PropertyEditModel editorType(String editorType)
+    {
+        _editorType = editorType;
+
+        return this;
+    }
+
+    public String getEditorType()
+    {
+        return _editorType;
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImpl.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImpl.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImpl.java Wed Jan 31 15:20:55 2007
@@ -14,13 +14,11 @@
 
 package org.apache.tapestry.internal.services;
 
-import java.util.Collections;
-import java.util.List;
+import java.util.Map;
 
 import org.apache.tapestry.ComponentResources;
 import org.apache.tapestry.beaneditor.BeanEditorModel;
-import org.apache.tapestry.beaneditor.Order;
-import org.apache.tapestry.beaneditor.PropertyEditModel;
+import org.apache.tapestry.events.InvalidationListener;
 import org.apache.tapestry.internal.beaneditor.BeanEditorModelImpl;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.ioc.internal.util.Defense;
@@ -28,19 +26,29 @@
 import org.apache.tapestry.ioc.services.PropertyAccess;
 import org.apache.tapestry.ioc.services.PropertyAdapter;
 import org.apache.tapestry.ioc.services.TypeCoercer;
+import org.apache.tapestry.ioc.util.StrategyRegistry;
 import org.apache.tapestry.services.BeanEditorModelSource;
 
-public class BeanEditorModelSourceImpl implements BeanEditorModelSource
+public class BeanEditorModelSourceImpl implements BeanEditorModelSource, InvalidationListener
 {
     private final TypeCoercer _typeCoercer;
 
     private final PropertyAccess _propertyAccess;
 
+    private final StrategyRegistry<String> _registry;
+
     public BeanEditorModelSourceImpl(final TypeCoercer typeCoercer,
-            final PropertyAccess propertyAccess)
+            final PropertyAccess propertyAccess, Map<Class, String> configuration)
     {
         _typeCoercer = typeCoercer;
         _propertyAccess = propertyAccess;
+
+        _registry = StrategyRegistry.newInstance(String.class, configuration);
+    }
+
+    public void objectWasInvalidated()
+    {
+        _registry.clearCache();
     }
 
     public BeanEditorModel create(Class beanClass, ComponentResources resources)
@@ -60,21 +68,17 @@
 
             if (pa.isRead() && pa.isUpdate())
             {
-                PropertyEditModel propertyModel = model.add(propertyName);
+                String editorType = _registry.get(pa.getType());
 
-                Order annotation = propertyModel.getConduit().getAnnotation(Order.class);
+                // If an unregistered type, then ignore the property.
 
-                if (annotation != null)
-                    propertyModel.order(annotation.value());
+                if (editorType.equals(""))
+                    continue;
+
+                model.add(propertyName).editorType(editorType);
             }
         }
 
         return model;
     }
-
-    public List<String> buildConstraints(PropertyEditModel propertyModel)
-    {
-        return Collections.emptyList();
-    }
-
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldValidatorSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldValidatorSource.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldValidatorSource.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/FieldValidatorSource.java Wed Jan 31 15:20:55 2007
@@ -19,7 +19,7 @@
 import org.apache.tapestry.Field;
 import org.apache.tapestry.FieldValidator;
 import org.apache.tapestry.Validator;
-import org.apache.tapestry.corelib.components.BeanEditor;
+import org.apache.tapestry.corelib.components.BeanEditForm;
 import org.apache.tapestry.ioc.Messages;
 
 /**
@@ -50,7 +50,7 @@
     /**
      * Full featured version of {@link #createValidator(Field, String, String)} used in situations
      * where the container of the field is not necesarrilly the place to look for override messages,
-     * and the id of the field is not the key to use when checking. The {@link BeanEditor} is an
+     * and the id of the field is not the key to use when checking. The {@link BeanEditForm} is an
      * example of this.
      * 
      * @param field

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/services/TapestryModule.java Wed Jan 31 15:20:55 2007
@@ -1133,12 +1133,37 @@
         return new ApplicationStateManagerImpl(configuration, source);
     }
 
-    public static BeanEditorModelSource buildBeanEditorModelSource(
-            @Inject("infrastructure:TypeCoercer")
-            TypeCoercer typeCoercer, @Inject("infrastructure:PropertyAccess")
-            PropertyAccess propertyAccess)
+    /**
+     * The configurationof the model source is a mapping from type to string. The types are property
+     * types and the values, the strings, represent different type of editors.
+     */
+    public BeanEditorModelSource buildBeanEditorModelSource(@Inject("infrastructure:TypeCoercer")
+    TypeCoercer typeCoercer, @Inject("infrastructure:PropertyAccess")
+    PropertyAccess propertyAccess, Map<Class, String> configuration)
     {
-        return new BeanEditorModelSourceImpl(typeCoercer, propertyAccess);
+        BeanEditorModelSourceImpl service = new BeanEditorModelSourceImpl(typeCoercer,
+                propertyAccess, configuration);
+
+        _componentInstantiatorSource.addInvalidationListener(service);
+
+        return service;
+    }
+
+    /**
+     * Maps types to corresponding property editor names:
+     * <ul>
+     * <li>String --&gt; text
+     * <li>Number --&gt; text
+     * <li>Enum --&gt; enum
+     * </ul>
+     */
+    public static void contributeBeanEditorModelSource(
+            MappedConfiguration<Class, String> configuration)
+    {
+        configuration.add(Object.class, "");
+        configuration.add(String.class, "text");
+        configuration.add(Number.class, "text");
+        configuration.add(Enum.class, "enum");
     }
 
     public static ValidationConstraintGenerator buildValidationConstraintGenerator(

Copied: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html (from r501975, tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.html)
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html?view=diff&rev=502037&p1=tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.html&r1=501975&p2=tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditor.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.html Wed Jan 31 15:20:55 2007
@@ -12,4 +12,9 @@
         <label t:type="Label" for="textField"/>                
         <input t:id="textField"/>
     </t:block>
+    
+    <t:block id="enum">
+        <label t:type="Label" for="select"/>
+        <input t:id="select"/>
+    </t:block>
 </form>

Added: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.properties?view=auto&rev=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.properties (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/corelib/components/BeanEditForm.properties Wed Jan 31 15:20:55 2007
@@ -0,0 +1,15 @@
+# Copyright 2007 The Apache Software Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+no-editor=The BeanEditor component does not include an editor of type '%s' (for property '%s').

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/BeanEditorDemo.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/BeanEditorDemo.html?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/BeanEditorDemo.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/BeanEditorDemo.html Wed Jan 31 15:20:55 2007
@@ -1,9 +1,8 @@
 <t:comp type="Border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
     <h1>BeanEditor Component Demo</h1>
     
-    <t:comp type="BeanEditor" object="registrationData"/>
-       
-       
+    <t:comp type="BeanEditForm" object="registrationData"/>
+              
     <p>
         [<a t:type="ActionLink" t:id="clear">Clear Data</a>]
     </p>        

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/app1/WEB-INF/ViewRegistration.html Wed Jan 31 15:20:55 2007
@@ -6,5 +6,7 @@
 Last Name: [${registrationData.lastName}]
 <br/>
 Birth year: [${registrationData.birthYear}]
+<br/>
+Sex: [${registrationData.sex}]
     
 </t:comp>

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/EnumSelectModelTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/EnumSelectModelTest.java?view=auto&rev=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/EnumSelectModelTest.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/EnumSelectModelTest.java Wed Jan 31 15:20:55 2007
@@ -0,0 +1,103 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry;
+
+import java.util.List;
+
+import org.apache.tapestry.ioc.Messages;
+import org.apache.tapestry.test.TapestryTestCase;
+import org.testng.annotations.Test;
+
+public class EnumSelectModelTest extends TapestryTestCase
+{
+    @Test
+    public void generated_labels()
+    {
+        Messages messages = newMessages();
+        stub_contains(messages, false);
+
+        replay();
+
+        SelectModel model = new EnumSelectModel(Stooge.class, messages);
+
+        List<OptionModel> options = model.getOptions();
+
+        assertEquals(options.size(), 3);
+
+        checkOption(options, 0, "Moe", Stooge.MOE);
+        checkOption(options, 1, "Larry", Stooge.LARRY);
+        checkOption(options, 2, "Curly Joe", Stooge.CURLY_JOE);
+
+        verify();
+    }
+
+    @Test
+    public void prefixed_name_in_message_catalog()
+    {
+        Messages messages = newMessages();
+        stub_contains(messages, false);
+
+        train_contains(messages, "Stooge.LARRY", true);
+        train_get(messages, "Stooge.LARRY", "Mr. Larry Fine");
+
+        replay();
+
+        SelectModel model = new EnumSelectModel(Stooge.class, messages);
+
+        List<OptionModel> options = model.getOptions();
+
+        assertEquals(options.size(), 3);
+
+        checkOption(options, 0, "Moe", Stooge.MOE);
+        checkOption(options, 1, "Mr. Larry Fine", Stooge.LARRY);
+        checkOption(options, 2, "Curly Joe", Stooge.CURLY_JOE);
+
+        verify();
+    }
+
+    @Test
+    public void unprefixed_name_in_message_catalog()
+    {
+        Messages messages = newMessages();
+        stub_contains(messages, false);
+
+        train_contains(messages, "MOE", true);
+        train_get(messages, "MOE", "Sir Moe Howard");
+
+        replay();
+
+        SelectModel model = new EnumSelectModel(Stooge.class, messages);
+
+        List<OptionModel> options = model.getOptions();
+
+        assertEquals(options.size(), 3);
+
+        checkOption(options, 0, "Sir Moe Howard", Stooge.MOE);
+        checkOption(options, 1, "Larry", Stooge.LARRY);
+        checkOption(options, 2, "Curly Joe", Stooge.CURLY_JOE);
+
+        verify();
+    }
+
+    private void checkOption(List<OptionModel> options, int i, String label, Stooge value)
+    {
+        OptionModel model = options.get(i);
+
+        assertEquals(model.getLabel(), label);
+        assertFalse(model.isDisabled());
+        assertSame(model.getValue(), value);
+        assertNull(model.getAttributes());
+    }
+}

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/Stooge.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/Stooge.java?view=auto&rev=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/Stooge.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/Stooge.java Wed Jan 31 15:20:55 2007
@@ -0,0 +1,19 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry;
+
+public enum Stooge {
+    MOE, LARRY, CURLY_JOE
+}

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=502037&r1=502036&r2=502037
==============================================================================
--- 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 Wed Jan 31 15:20:55 2007
@@ -708,14 +708,16 @@
         _selenium.open(BASE_URL);
         clickAndWait("link=BeanEditor Demo");
         clickAndWait(submitButton);
+
         assertTextPresent(
                 "You must provide a value for First Name.",
-                "Everyone has to have last name!",
+                "Everyone has to have a last name!",
                 "Year of Birth requires a value of at least 1900.");
 
         _selenium.type("textField", "a");
         _selenium.type("textField_0", "b");
         _selenium.type("textField_1", "");
+        _selenium.select("select", "label=Martian");
 
         clickAndWait(submitButton);
 
@@ -730,6 +732,6 @@
 
         clickAndWait(submitButton);
 
-        assertTextPresent("[Howard]", "[Lewis Ship]", "[1966]");
+        assertTextPresent("[Howard]", "[Lewis Ship]", "[1966]", "[MARTIAN]");
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java Wed Jan 31 15:20:55 2007
@@ -25,6 +25,8 @@
 
     private int _birthYear;
 
+    private Sex _sex = Sex.MALE;
+
     @Order(300)
     @Validate("min=1900,max=2007")
     public int getBirthYear()
@@ -59,5 +61,16 @@
     public void setLastName(String lastName)
     {
         _lastName = lastName;
+    }
+
+    public Sex getSex()
+    {
+        return _sex;
+    }
+
+    @Order(400)
+    public void setSex(Sex sex)
+    {
+        _sex = sex;
     }
 }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Sex.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Sex.java?view=auto&rev=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Sex.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/integration/app1/data/Sex.java Wed Jan 31 15:20:55 2007
@@ -0,0 +1,19 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.integration.app1.data;
+
+public enum Sex {
+    MALE, FEMALE, TRANSGENDERED, MARTIAN
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/TapestryUtilsTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/TapestryUtilsTest.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/TapestryUtilsTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/TapestryUtilsTest.java Wed Jan 31 15:20:55 2007
@@ -94,7 +94,8 @@
         {
         { "hello", "Hello" },
         { "userId", "User Id" },
-        { "useHTML", "Use HTML" }, };
+        { "useHTML", "Use HTML" },
+        { "underscored_name", "Underscored Name" }, };
     }
 
     @Test

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImplTest.java?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/BeanEditorModelSourceImplTest.java Wed Jan 31 15:20:55 2007
@@ -60,11 +60,17 @@
 
         assertEquals(model.getPropertyNames(), Arrays.asList("age", "firstName", "lastName"));
 
-        assertEquals(model.get("age").getLabel(), "Age");
-        assertSame(model.get("age").getPropertyType(), int.class);
+        PropertyEditModel age = model.get("age");
 
-        assertEquals(model.get("firstName").getLabel(), "First Name");
-        assertEquals(model.get("firstName").getPropertyType(), String.class);
+        assertEquals(age.getLabel(), "Age");
+        assertSame(age.getPropertyType(), int.class);
+        assertEquals(age.getEditorType(), "text");
+
+        PropertyEditModel firstName = model.get("firstName");
+
+        assertEquals(firstName.getLabel(), "First Name");
+        assertEquals(firstName.getPropertyType(), String.class);
+        assertEquals(firstName.getEditorType(), "text");
 
         assertEquals(model.get("lastName").getLabel(), "Last Name");
 
@@ -82,9 +88,29 @@
 
         // Now, one with some type coercion.
 
-        model.get("age").getConduit().write(instance, "40");
+        age.getConduit().write(instance, "40");
 
         assertEquals(instance.getAge(), 40);
+
+        verify();
+    }
+
+    @Test
+    public void non_text_property()
+    {
+        ComponentResources resources = newComponentResources();
+        Messages messages = newMessages();
+
+        train_getMessages(resources, messages);
+        stub_contains(messages, false);
+
+        replay();
+
+        BeanEditorModel model = _source.create(EnumBean.class, resources);
+
+        assertEquals(model.getPropertyNames(), Arrays.asList("token"));
+
+        assertEquals(model.get("token").getEditorType(), "enum");
 
         verify();
     }

Added: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/EnumBean.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/EnumBean.java?view=auto&rev=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/EnumBean.java (added)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/EnumBean.java Wed Jan 31 15:20:55 2007
@@ -0,0 +1,33 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+import org.apache.tapestry.internal.parser.TokenType;
+
+public class EnumBean
+{
+    private TokenType _token;
+
+    public TokenType getToken()
+    {
+        return _token;
+    }
+
+    public void setToken(TokenType token)
+    {
+        _token = token;
+    }
+
+}

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties?view=diff&rev=502037&r1=502036&r2=502037
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/BeanEditorDemo.properties Wed Jan 31 15:20:55 2007
@@ -13,4 +13,4 @@
 # limitations under the License.
 
 birthYear-label=Year of Birth
-lastName-required=Everyone has to have last name!
\ No newline at end of file
+lastName-required=Everyone has to have a last name!
\ No newline at end of file