tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From freem...@apache.org
Subject svn commit: r503433 [2/2] - in /tapestry/tapestry5/tapestry-core/trunk: ./ src/main/java/org/apache/tapestry/ src/main/java/org/apache/tapestry/annotations/ src/main/java/org/apache/tapestry/beaneditor/ src/main/java/org/apache/tapestry/corelib/base/ s...
Date Sun, 04 Feb 2007 16:07:34 GMT
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=503433&r1=503432&r2=503433
==============================================================================
--- 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 Sun Feb  4 08:07:30 2007
@@ -30,6 +30,7 @@
 import org.apache.tapestry.MarkupWriter;
 import org.apache.tapestry.SelectModel;
 import org.apache.tapestry.Translator;
+import org.apache.tapestry.Validator;
 import org.apache.tapestry.annotations.AfterRender;
 import org.apache.tapestry.annotations.AfterRenderBody;
 import org.apache.tapestry.annotations.AfterRenderTemplate;
@@ -39,21 +40,18 @@
 import org.apache.tapestry.annotations.CleanupRender;
 import org.apache.tapestry.annotations.InjectPage;
 import org.apache.tapestry.annotations.SetupRender;
+import org.apache.tapestry.beaneditor.Validate;
 import org.apache.tapestry.dom.DefaultMarkupModel;
 import org.apache.tapestry.dom.Document;
 import org.apache.tapestry.internal.InternalConstants;
 import org.apache.tapestry.internal.TapestryUtils;
-import org.apache.tapestry.internal.beaneditor.AnnotationValidatorGenerator;
-import org.apache.tapestry.internal.beaneditor.LengthRangeValidateAnnotationWorker;
-import org.apache.tapestry.internal.beaneditor.MaxValidateAnnotationWorker;
-import org.apache.tapestry.internal.beaneditor.MinValidateAnnotationWorker;
-import org.apache.tapestry.internal.beaneditor.PrimitiveFieldValidatorGenerator;
-import org.apache.tapestry.internal.beaneditor.RequiredValidateAnnotationWorker;
-import org.apache.tapestry.internal.beaneditor.ValidateAnnotationWorker;
+import org.apache.tapestry.internal.beaneditor.PrimitiveFieldConstraintGenerator;
+import org.apache.tapestry.internal.beaneditor.ValidateAnnotationConstraintGenerator;
 import org.apache.tapestry.internal.bindings.ComponentBindingFactory;
 import org.apache.tapestry.internal.bindings.LiteralBindingFactory;
 import org.apache.tapestry.internal.bindings.MessageBindingFactory;
 import org.apache.tapestry.internal.bindings.TranslateBindingFactory;
+import org.apache.tapestry.internal.bindings.ValidateBindingFactory;
 import org.apache.tapestry.internal.services.ActionLinkHandler;
 import org.apache.tapestry.internal.services.ActionLinkHandlerImpl;
 import org.apache.tapestry.internal.services.ApplicationGlobalsImpl;
@@ -82,14 +80,13 @@
 import org.apache.tapestry.internal.services.CookieSink;
 import org.apache.tapestry.internal.services.CookieSource;
 import org.apache.tapestry.internal.services.CookiesImpl;
+import org.apache.tapestry.internal.services.FieldValidatorDefaultSourceImpl;
 import org.apache.tapestry.internal.services.DefaultInjectionProvider;
 import org.apache.tapestry.internal.services.DefaultValidationDelegateCommand;
 import org.apache.tapestry.internal.services.EnvironmentImpl;
 import org.apache.tapestry.internal.services.EnvironmentalWorker;
-import org.apache.tapestry.internal.services.FieldValidatorMessages;
-import org.apache.tapestry.internal.services.FieldValidatorMessagesImpl;
+import org.apache.tapestry.internal.services.FieldValidatorSourceImpl;
 import org.apache.tapestry.internal.services.FlashPersistentFieldStrategy;
-import org.apache.tapestry.internal.services.FormPersistWorker;
 import org.apache.tapestry.internal.services.HeartbeatImpl;
 import org.apache.tapestry.internal.services.InfrastructureImpl;
 import org.apache.tapestry.internal.services.InfrastructureManagerImpl;
@@ -136,8 +133,8 @@
 import org.apache.tapestry.internal.services.TranslatorSourceImpl;
 import org.apache.tapestry.internal.services.UnclaimedFieldWorker;
 import org.apache.tapestry.internal.services.UpdateListenerHub;
+import org.apache.tapestry.internal.services.ValidationConstraintGeneratorImpl;
 import org.apache.tapestry.internal.services.ValidationMessagesSourceImpl;
-import org.apache.tapestry.internal.services.CompoundalidatorGenerator;
 import org.apache.tapestry.ioc.Configuration;
 import org.apache.tapestry.ioc.IOCUtilities;
 import org.apache.tapestry.ioc.MappedConfiguration;
@@ -169,6 +166,11 @@
 import org.apache.tapestry.translator.IntegerTranslator;
 import org.apache.tapestry.translator.LongTranslator;
 import org.apache.tapestry.translator.StringTranslator;
+import org.apache.tapestry.validator.Max;
+import org.apache.tapestry.validator.MaxLength;
+import org.apache.tapestry.validator.Min;
+import org.apache.tapestry.validator.MinLength;
+import org.apache.tapestry.validator.Required;
 
 /**
  * The root module for Tapestry.
@@ -469,8 +471,7 @@
      */
     public static void contributeInfrastructure(
             Configuration<InfrastructureContribution> configuration, ServiceLocator locator,
-            @InjectService("ValidatorGenerator")
-            ValidatorGenerator validatorGenerator, @InjectService("tapestry.ioc.TypeCoercer")
+            @InjectService("tapestry.ioc.TypeCoercer")
             TypeCoercer typeCoercer, @InjectService("tapestry.ioc.PropertyAccess")
             PropertyAccess propertyAccess)
 
@@ -490,6 +491,8 @@
                 ComponentMessagesSource.class,
                 ComponentSource.class,
                 Environment.class,
+                FieldValidatorDefaultSource.class,
+                FieldValidatorSource.class,
                 MarkupWriterFactory.class,
                 PersistentFieldManager.class,
                 Request.class,
@@ -498,10 +501,9 @@
                 Response.class,
                 TranslatorDefaultSource.class,
                 TranslatorSource.class,
-                ValidationMessagesSource.class,
-                FieldValidatorMessages.class);
+                ValidationConstraintGenerator.class,
+                ValidationMessagesSource.class);
 
-        configuration.add(new InfrastructureContribution("ValidatorGenerator", validatorGenerator));
         configuration.add(new InfrastructureContribution("TypeCoercer", typeCoercer));
         configuration.add(new InfrastructureContribution("PropertyAccess", propertyAccess));
     }
@@ -588,13 +590,15 @@
     public static void contributeBindingSource(
             MappedConfiguration<String, BindingFactory> configuration,
             @InjectService("tapestry.internal.PropBindingFactory")
-            BindingFactory propBindingFactory, @Inject("infrastructure:TranslatorSource")
+            BindingFactory propBindingFactory, @Inject("infrastructure:FieldValidatorSource")
+            FieldValidatorSource fieldValidatorSource, @Inject("infrastructure:TranslatorSource")
             TranslatorSource translatorSource)
     {
         configuration.add(InternalConstants.LITERAL_BINDING_PREFIX, new LiteralBindingFactory());
         configuration.add(InternalConstants.PROP_BINDING_PREFIX, propBindingFactory);
         configuration.add("component", new ComponentBindingFactory());
         configuration.add("message", new MessageBindingFactory());
+        configuration.add("validate", new ValidateBindingFactory(fieldValidatorSource));
         configuration.add("translate", new TranslateBindingFactory(translatorSource));
     }
 
@@ -737,7 +741,6 @@
 
         configuration.add("Retain", new RetainWorker());
         configuration.add("Persist", new PersistWorker());
-        configuration.add("RestoreOnSubmit", new FormPersistWorker());
         configuration.add("UnclaimedField", new UnclaimedFieldWorker(), "after:*.*");
     }
 
@@ -924,11 +927,32 @@
         configuration.add("tapestry/", "org/apache/tapestry/");
     }
 
-    public static FieldValidatorMessages buildFieldValidatorMessages(
+    public static FieldValidatorSource buildFieldValidatorSource(
             @Inject("infrastructure:ValidationMessagesSource")
-            ValidationMessagesSource messagesSource)
+            ValidationMessagesSource messagesSource, @Inject("infrastructure:TypeCoercer")
+            TypeCoercer typeCoercer, Map<String, Validator> configuration)
     {
-        return new FieldValidatorMessagesImpl(messagesSource);
+        return new FieldValidatorSourceImpl(messagesSource, typeCoercer, configuration);
+    }
+
+    /**
+     * Contributes the basic set of validators:
+     * <ul>
+     * <li>required</li>
+     * <li>minlength</li>
+     * <li>maxlength</li>
+     * <li>min</li>
+     * <li>max</li>
+     * </ul>
+     */
+    public static void contributeFieldValidatorSource(
+            MappedConfiguration<String, Validator> configuration)
+    {
+        configuration.add("required", new Required());
+        configuration.add("minlength", new MinLength());
+        configuration.add("maxlength", new MaxLength());
+        configuration.add("min", new Min());
+        configuration.add("max", new Max());
     }
 
     public static TranslatorSource buildTranslatorSource(Map<String, Translator> configuration)
@@ -1147,40 +1171,33 @@
         configuration.add(Boolean.class, "checkbox");
     }
 
-    public static ValidatorGenerator buildValidatorGenerator(List<ValidatorGenerator> configuration)
+    public static ValidationConstraintGenerator buildValidationConstraintGenerator(
+            List<ValidationConstraintGenerator> configuration)
     {
-        return new CompoundalidatorGenerator(configuration);
+        return new ValidationConstraintGeneratorImpl(configuration);
     }
 
     /**
-     * Adds built-in validator generators:
+     * Adds built-in constraint generators:
      * <ul>
      * <li>PrimtiveField -- primitive fields are always required
-     * <li>Annotation -- adds constraints from a various annotations
+     * <li>ValidateAnnotation -- adds constraints from a {@link Validate} annotation
      * </ul>
      */
-    public static void contributeValidatorGenerator(
-            OrderedConfiguration<ValidatorGenerator> configuration,
-            @InjectService("AnnotationValidatorGenerator")
-            ValidatorGenerator annotationValidatorGenerator)
+    public static void contributeValidationConstraintGenerator(
+            OrderedConfiguration<ValidationConstraintGenerator> configuration)
     {
-        configuration.add("PrimitiveField", new PrimitiveFieldValidatorGenerator());
-        configuration.add("Annotation", annotationValidatorGenerator);
+        configuration.add("PrimitiveField", new PrimitiveFieldConstraintGenerator());
+        configuration.add("ValidateAnnotation", new ValidateAnnotationConstraintGenerator());
     }
 
-    public static ValidatorGenerator buildAnnotationValidatorGenerator(
-            List<ValidateAnnotationWorker> configuration)
+    public static FieldValidatorDefaultSource buildFieldValidatorDefaultSource(
+            @Inject("infrastructure:ValidationConstraintGenerator")
+            ValidationConstraintGenerator validationConstraintGenerator,
+            @Inject("infrastructure:FieldValidatorSource")
+            FieldValidatorSource fieldValidatorSource)
     {
-        return new AnnotationValidatorGenerator(configuration);
+        return new FieldValidatorDefaultSourceImpl(validationConstraintGenerator,
+                fieldValidatorSource);
     }
-
-    public static void contributeAnnotationValidatorGenerator(
-            OrderedConfiguration<ValidateAnnotationWorker> configuration)
-    {
-        configuration.add("required", new RequiredValidateAnnotationWorker());
-        configuration.add("min", new MinValidateAnnotationWorker());
-        configuration.add("max", new MaxValidateAnnotationWorker());
-        configuration.add("lengthRange", new LengthRangeValidateAnnotationWorker());
-    }
-
 }

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=503433&r1=503432&r2=503433
==============================================================================
--- 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 Sun Feb  4 08:07:30 2007
@@ -72,6 +72,7 @@
 import org.apache.tapestry.services.ComponentClassResolver;
 import org.apache.tapestry.services.Context;
 import org.apache.tapestry.services.Environment;
+import org.apache.tapestry.services.FieldValidatorSource;
 import org.apache.tapestry.services.Heartbeat;
 import org.apache.tapestry.services.InjectionProvider;
 import org.apache.tapestry.services.MethodFilter;
@@ -81,6 +82,7 @@
 import org.apache.tapestry.services.ResourceDigestGenerator;
 import org.apache.tapestry.services.Response;
 import org.apache.tapestry.services.Session;
+import org.apache.tapestry.services.ValidationConstraintGenerator;
 import org.apache.tapestry.services.ValidationMessagesSource;
 import org.easymock.EasyMock;
 import org.easymock.IAnswer;
@@ -530,6 +532,11 @@
         expect(resources.getLocale()).andReturn(locale).atLeastOnce();
     }
 
+    protected <C, T> void train_getConstraintType(Validator<C, T> validator, Class<C> constraintType)
+    {
+        expect(validator.getConstraintType()).andReturn(constraintType);
+    }
+
     protected final Validator newValidator()
     {
         return newMock(Validator.class);
@@ -545,6 +552,11 @@
         return newMock(FieldValidator.class);
     }
 
+    protected FieldValidatorSource newFieldValidatorSource()
+    {
+        return newMock(FieldValidatorSource.class);
+    }
+
     protected final Component newComponent()
     {
         return newMock(Component.class);
@@ -705,6 +717,11 @@
         expect(resources.getMessages()).andReturn(messages).atLeastOnce();
     }
 
+    protected final void train_getValueType(Validator validator, Class valueType)
+    {
+        expect(validator.getValueType()).andReturn(valueType).atLeastOnce();
+    }
+
     protected final void train_invokeIfBlank(Validator validator, boolean invokeIfBlank)
     {
         expect(validator.invokeIfBlank()).andReturn(invokeIfBlank).atLeastOnce();
@@ -784,4 +801,26 @@
         return newMock(AnnotationProvider.class);
     }
 
+    protected final void train_createValidator(FieldValidatorSource source, Field field, String validatorType, String constraintValue, String overrideId, Messages overrideMessages, Locale locale, FieldValidator result)
+    {
+        expect(
+                source.createValidator(
+                        field,
+                        validatorType,
+                        constraintValue,
+                        overrideId,
+                        overrideMessages,
+                        locale)).andReturn(result);
+    }
+
+    protected final void train_buildConstraints(ValidationConstraintGenerator generator, Class propertyType, AnnotationProvider provider, String... constraints)
+    {
+        expect(generator.buildConstraints(propertyType, provider)).andReturn(
+                Arrays.asList(constraints));
+    }
+
+    protected final ValidationConstraintGenerator newValidationConstraintGenerator()
+    {
+        return newMock(ValidationConstraintGenerator.class);
+    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/DoubleTranslator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/DoubleTranslator.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/DoubleTranslator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/DoubleTranslator.java Sun Feb  4 08:07:30 2007
@@ -14,17 +14,13 @@
 
 package org.apache.tapestry.translator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Translator;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
 
-public class DoubleTranslator implements Translator<Double>, Serializable
+public class DoubleTranslator implements Translator<Double>
 {
-    private static final long serialVersionUID = 1L;
-
     /**
      * Parses blank values to null, otherwise parses the client value to a long
      * 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/IntegerTranslator.java Sun Feb  4 08:07:30 2007
@@ -14,8 +14,6 @@
 
 package org.apache.tapestry.translator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Translator;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.ioc.Messages;
@@ -24,10 +22,8 @@
 /**
  * A translator for type integer.
  */
-public final class IntegerTranslator implements Translator<Integer>, Serializable
+public final class IntegerTranslator implements Translator<Integer>
 {
-    private static final long serialVersionUID = 1L;
-
     /**
      * Parses blank values to null, otherwise parses the client value to an integer.
      * 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/LongTranslator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/LongTranslator.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/LongTranslator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/LongTranslator.java Sun Feb  4 08:07:30 2007
@@ -14,18 +14,14 @@
 
 package org.apache.tapestry.translator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Translator;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.ioc.Messages;
 import org.apache.tapestry.ioc.internal.util.InternalUtils;
 
 /** A translator for type long. */
-public class LongTranslator implements Translator<Long>, Serializable
+public class LongTranslator implements Translator<Long>
 {
-    private static final long serialVersionUID = 1L;
-
     /**
      * Parses blank values to null, otherwise parses the client value to a long
      * 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/StringTranslator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/StringTranslator.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/StringTranslator.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/translator/StringTranslator.java Sun Feb  4 08:07:30 2007
@@ -14,16 +14,12 @@
 
 package org.apache.tapestry.translator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Translator;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.ioc.Messages;
 
-public class StringTranslator implements Translator<String>, Serializable
+public class StringTranslator implements Translator<String>
 {
-    private static final long serialVersionUID = 1L;
-
     /** Returns the client value (or the empty string, if the client value is null). */
     public String parseClient(String clientValue, Messages messages) throws ValidationException
     {

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Max.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Max.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Max.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Max.java Sun Feb  4 08:07:30 2007
@@ -14,23 +14,17 @@
 
 package org.apache.tapestry.validator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Field;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.Validator;
 import org.apache.tapestry.ioc.MessageFormatter;
 
 /** Enforces a maximum integer value. */
-public class Max implements Validator<Number>, Serializable
+public class Max implements Validator<Long, Number>
 {
-    private static final long serialVersionUID = 1L;
-
-    private long _max;
-    
-    public Max(long max)
+    public Class<Long> getConstraintType()
     {
-        _max = max;
+        return Long.class;
     }
 
     public String getMessageKey()
@@ -38,15 +32,20 @@
         return "max-integer";
     }
 
+    public Class<Number> getValueType()
+    {
+        return Number.class;
+    }
+
     public boolean invokeIfBlank()
     {
         return false;
     }
 
-    public void validate(Field field, MessageFormatter formatter, Number value)
+    public void validate(Field field, Long constraintValue, MessageFormatter formatter, Number value)
             throws ValidationException
     {
-        if (value.longValue() > _max)
-            throw new ValidationException(formatter.format(_max, field.getLabel()));
+        if (value.longValue() > constraintValue)
+            throw new ValidationException(formatter.format(constraintValue, field.getLabel()));
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/MaxLength.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/MaxLength.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/MaxLength.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/MaxLength.java Sun Feb  4 08:07:30 2007
@@ -14,22 +14,16 @@
 
 package org.apache.tapestry.validator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Field;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.Validator;
 import org.apache.tapestry.ioc.MessageFormatter;
 
-public final class MaxLength implements Validator<String>, Serializable
+public final class MaxLength implements Validator<Integer, String>
 {
-    private static final long serialVersionUID = 1L;
-
-    private int _maxLength;
-
-    public MaxLength(int maxLength)
+    public Class<Integer> getConstraintType()
     {
-        _maxLength = maxLength;
+        return Integer.class;
     }
 
     public String getMessageKey()
@@ -37,15 +31,20 @@
         return "maximum-string-length";
     }
 
+    public Class<String> getValueType()
+    {
+        return String.class;
+    }
+
     public boolean invokeIfBlank()
     {
         return false;
     }
 
-    public void validate(Field field, MessageFormatter formatter, String value)
+    public void validate(Field field, Integer constraintValue, MessageFormatter formatter, String value)
             throws ValidationException
     {
-        if (value.length() > _maxLength)
-            throw new ValidationException(formatter.format(_maxLength, field.getLabel()));
+        if (value.length() > constraintValue)
+            throw new ValidationException(formatter.format(constraintValue, field.getLabel()));
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Min.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Min.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Min.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Min.java Sun Feb  4 08:07:30 2007
@@ -14,23 +14,17 @@
 
 package org.apache.tapestry.validator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Field;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.Validator;
 import org.apache.tapestry.ioc.MessageFormatter;
 
 /* A vaidator that enforces that a number is greater than some minimum integer value. */
-public class Min implements Validator<Number>, Serializable
+public class Min implements Validator<Long, Number>
 {
-    private static final long serialVersionUID = 1L;
-    
-    private long _min;
-
-    public Min(long min)
+    public Class<Long> getConstraintType()
     {
-        _min = min;
+        return Long.class;
     }
 
     public String getMessageKey()
@@ -38,15 +32,20 @@
         return "min-integer";
     }
 
+    public Class<Number> getValueType()
+    {
+        return Number.class;
+    }
+
     public boolean invokeIfBlank()
     {
         return false;
     }
 
-    public void validate(Field field, MessageFormatter formatter, Number value)
+    public void validate(Field field, Long constraintValue, MessageFormatter formatter, Number value)
             throws ValidationException
     {
-        if (value.longValue() < _min)
-            throw new ValidationException(formatter.format(_min, field.getLabel()));
+        if (value.longValue() < constraintValue)
+            throw new ValidationException(formatter.format(constraintValue, field.getLabel()));
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/MinLength.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/MinLength.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/MinLength.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/MinLength.java Sun Feb  4 08:07:30 2007
@@ -14,8 +14,6 @@
 
 package org.apache.tapestry.validator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Field;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.Validator;
@@ -24,26 +22,23 @@
 /**
  * Validates that a string value has a minimum length.
  */
-public final class MinLength implements Validator<String>, Serializable
+public final class MinLength implements Validator<Integer, String>
 {
-    private static final long serialVersionUID = 1L;
-
-    private int _minLength;
-
-    public MinLength(int minLength)
-    {
-        _minLength = minLength;
-    }
     public String getMessageKey()
     {
         return "minimum-string-length";
     }
 
-    public void validate(Field field, MessageFormatter formatter,
+    public void validate(Field field, Integer constraintValue, MessageFormatter formatter,
             String value) throws ValidationException
     {
-        if (value.length() < _minLength)
-            throw new ValidationException(formatter.format(_minLength, field.getLabel()));
+        if (value.length() < constraintValue)
+            throw new ValidationException(formatter.format(constraintValue, field.getLabel()));
+    }
+
+    public Class<Integer> getConstraintType()
+    {
+        return Integer.class;
     }
 
     public boolean invokeIfBlank()
@@ -51,4 +46,8 @@
         return false;
     }
 
+    public Class<String> getValueType()
+    {
+        return String.class;
+    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Required.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Required.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Required.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/validator/Required.java Sun Feb  4 08:07:30 2007
@@ -14,8 +14,6 @@
 
 package org.apache.tapestry.validator;
 
-import java.io.Serializable;
-
 import org.apache.tapestry.Field;
 import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.Validator;
@@ -25,25 +23,32 @@
  * A validator that enforces that the value is not null and not the empty string. This validator is
  * not configurable.
  */
-public final class Required implements Validator<Object>, Serializable
+public final class Required implements Validator<Void, Object>
 {
-    private static final long serialVersionUID = 1L;
-
     public String getMessageKey()
     {
         return "required";
     }
 
-    public void validate(Field field, MessageFormatter formatter, Object value)
+    public void validate(Field field, Void constraintValue, MessageFormatter formatter, Object value)
             throws ValidationException
     {
         if (value == null || value.toString().equals(""))
             throw new ValidationException(formatter.format(field.getLabel()));
     }
 
+    public Class<Void> getConstraintType()
+    {
+        return null;
+    }
+
     public boolean invokeIfBlank()
     {
         return true;
     }
 
+    public Class<Object> getValueType()
+    {
+        return Object.class;
+    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ValidationMessages.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ValidationMessages.properties?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ValidationMessages.properties (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/resources/org/apache/tapestry/internal/ValidationMessages.properties Sun Feb  4 08:07:30 2007
@@ -19,7 +19,6 @@
 minimum-string-length=You must provide at least %d characters for %s.
 maximum-string-length=You may provide at most %d characters for %s.
 min-integer=%2$s requires a value of at least %1$d. 
-max-integer=%2$s requires a value of at most %1$d. 
 
 # This is where the translator messages go.
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/OptionGroupModelImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/OptionGroupModelImplTest.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/OptionGroupModelImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/OptionGroupModelImplTest.java Sun Feb  4 08:07:30 2007
@@ -28,9 +28,9 @@
     @Test
     public void basics()
     {
-        List<OptionModel<String>> options = Collections.emptyList();
+        List<OptionModel> options = Collections.emptyList();
 
-        OptionGroupModel<String> group = new OptionGroupModelImpl<String>("Label", true, options);
+        OptionGroupModel group = new OptionGroupModelImpl("Label", true, options);
 
         assertEquals(group.toString(), "OptionGroupModel[Label]");
         assertTrue(group.isDisabled());
@@ -41,11 +41,10 @@
     @Test
     public void map_contructor_retains_map()
     {
-        List<OptionModel<String>> options = Collections.emptyList();
+        List<OptionModel> options = Collections.emptyList();
         Map<String, String> attributes = Collections.emptyMap();
 
-        OptionGroupModel<String> group = new OptionGroupModelImpl<String>("Label", true, options,
-                attributes);
+        OptionGroupModel group = new OptionGroupModelImpl("Label", true, options, attributes);
 
         assertSame(group.getAttributes(), attributes);
     }
@@ -53,10 +52,10 @@
     @Test
     public void strings_contructor_builds_map()
     {
-        List<OptionModel<String>> options = Collections.emptyList();
+        List<OptionModel> options = Collections.emptyList();
 
-        OptionGroupModel<String> group = new OptionGroupModelImpl<String>("Label", true, options,
-                "fred", "flintstone", "barney", "rubble");
+        OptionGroupModel group = new OptionGroupModelImpl("Label", true, options, "fred",
+                "flintstone", "barney", "rubble");
 
         Map<String, String> attributes = group.getAttributes();
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/OptionModelImplTest.java Sun Feb  4 08:07:30 2007
@@ -26,14 +26,14 @@
     @Test
     public void basics()
     {
-        OptionModel<?> model = new OptionModelImpl<Object>("Label", false, this);
+        OptionModel model = new OptionModelImpl("Label", false, this);
 
         assertEquals(model.getLabel(), "Label");
         assertFalse(model.isDisabled());
         assertSame(model.getValue(), this);
         assertNull(model.getAttributes());
 
-        model = new OptionModelImpl<String>("Fred", true, "fred");
+        model = new OptionModelImpl("Fred", true, "fred");
 
         assertEquals(model.getLabel(), "Fred");
         assertTrue(model.isDisabled());
@@ -44,8 +44,8 @@
     @Test
     public void attributes_as_extra_parameters()
     {
-        OptionModel<?> model = new OptionModelImpl<Object>("Label", false, this, "fred",
-                "flintstone", "barney", "rubble");
+        OptionModel model = new OptionModelImpl("Label", false, this, "fred", "flintstone",
+                "barney", "rubble");
 
         Map<String, String> attributes = model.getAttributes();
 
@@ -59,7 +59,7 @@
     {
         Map<String, String> attributes = Collections.emptyMap();
 
-        OptionModel<?> model = new OptionModelImpl<Object>("Label", false, this, attributes);
+        OptionModel model = new OptionModelImpl("Label", false, this, attributes);
 
         assertSame(model.getAttributes(), attributes);
     }

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=503433&r1=503432&r2=503433
==============================================================================
--- 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 Sun Feb  4 08:07:30 2007
@@ -133,7 +133,7 @@
     @Test
     public void to_option_models()
     {
-        List<OptionModel<String>> options = TapestryUtils.toOptionModels("UK,USA,DE=Germany");
+        List<OptionModel> options = TapestryUtils.toOptionModels("UK,USA,DE=Germany");
 
         assertEquals(options.size(), 3);
 
@@ -150,7 +150,7 @@
     @Test
     public void whitespace_around_terms_is_trimmed()
     {
-        List<OptionModel<String>> options = TapestryUtils.toOptionModels(" UK , USA , DE=Germany ");
+        List<OptionModel> options = TapestryUtils.toOptionModels(" UK , USA , DE=Germany ");
 
         assertEquals(options.size(), 3);
 

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorImplTest.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorImplTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/services/FieldValidatorImplTest.java Sun Feb  4 08:07:30 2007
@@ -16,12 +16,9 @@
 
 import org.apache.tapestry.Field;
 import org.apache.tapestry.FieldValidator;
-import org.apache.tapestry.ValidationException;
 import org.apache.tapestry.Validator;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.MessageFormatter;
-import org.apache.tapestry.validator.Max;
-import org.apache.tapestry.validator.Min;
 import org.testng.annotations.Test;
 
 /**
@@ -29,200 +26,83 @@
  */
 public class FieldValidatorImplTest extends InternalBaseTestCase
 {
-    @SuppressWarnings("serial")
+    @SuppressWarnings("unchecked")
     @Test
     public void null_value_skipped() throws Exception
     {
-        Field field = null;
-        FieldValidatorMessages messages = new FieldValidatorMessages()
-        {
-            public MessageFormatter get(Field field, Validator validator)
-            {
-                return null;
-            }
-
-        };
-        Validator<Object> validator = new NoOpValidator<Object>()
-        {
-
-            @Override
-            public void validate(Field field, MessageFormatter formatter, Object value)
-                    throws ValidationException
-            {
-                fail();
-            }
-        };
+        Field field = newField();
+        MessageFormatter formatter = newMessageFormatter();
+        Validator validator = newValidator();
 
-        FieldValidator<Object> fv = new FieldValidatorImpl<Object>(field, messages, validator);
+        train_invokeIfBlank(validator, false);
+
+        replay();
+
+        FieldValidator fv = new FieldValidatorImpl(field, null, formatter, validator);
 
         fv.validate(null);
+
+        verify();
     }
 
-    @SuppressWarnings("serial")
+    @SuppressWarnings("unchecked")
     @Test
     public void blank_value_skipped() throws Exception
     {
-        Field field = null;
-        FieldValidatorMessages messages = new FieldValidatorMessages()
-        {
-            public MessageFormatter get(Field field, Validator validator)
-            {
-                return null;
-            }
-
-        };
-        Validator<Object> validator = new NoOpValidator<Object>()
-        {
-
-            @Override
-            public void validate(Field field, MessageFormatter formatter, Object value)
-                    throws ValidationException
-            {
-                fail();
-            }
-        };
+        Field field = newField();
+        MessageFormatter formatter = newMessageFormatter();
+        Validator validator = newValidator();
+
+        train_invokeIfBlank(validator, false);
+
+        replay();
 
-        FieldValidator<Object> fv = new FieldValidatorImpl<Object>(field, messages, validator);
+        FieldValidator fv = new FieldValidatorImpl(field, null, formatter, validator);
 
         fv.validate("");
 
+        verify();
     }
 
+    @SuppressWarnings("unchecked")
     @Test
-    public void single_validator() throws Exception
+    public void nonmatching_value_type_skipped() throws Exception
     {
-        final Field field = new NoOpField()
-        {
+        Field field = newField();
+        MessageFormatter formatter = newMessageFormatter();
+        Validator validator = newValidator();
+        Integer value = 15;
 
-            @Override
-            public String getLabel()
-            {
-                return "foo";
-            }
-
-        };
-        final Min min = new Min(10);
-        FieldValidatorMessages messages = new FieldValidatorMessages()
-        {
-            public MessageFormatter get(Field field2, Validator validator)
-            {
-                assertSame(field2, field);
-                assertSame(validator, min);
-                return new MessageFormatter()
-                {
-
-                    public String format(Object... args)
-                    {
-                        return String.format("%2$s must be at least %1$s", args);
-                    }
-
-                };
-            }
-
-        };
-        FieldValidator<Number> fv = new FieldValidatorImpl<Number>(field, messages, min);
-        fv.validate(10);
-        fv.validate(11);
-        try
-        {
-            fv.validate(9);
-            unreachable();
-        }
-        catch (ValidationException ex)
-        {
-            assertEquals(ex.getMessage(), "foo must be at least 10");
-        }
-    }
+        train_invokeIfBlank(validator, true);
+        train_getValueType(validator, String.class);
 
-    @Test
-    public void two_validators() throws Exception
-    {
-        final Field field = new NoOpField()
-        {
+        replay();
+
+        FieldValidator fv = new FieldValidatorImpl(field, null, formatter, validator);
 
-            @Override
-            public String getLabel()
-            {
-                return "foo";
-            }
-
-        };
-        final Min min = new Min(10);
-        final Max max = new Max(12);
-        FieldValidatorMessages messages = new FieldValidatorMessages()
-        {
-            public MessageFormatter get(Field field2, Validator validator)
-            {
-                assertSame(field2, field);
-                if (validator == min)
-                {
-                    return null;
-                }
-                return validator == max ? new MessageFormatter()
-                {
-
-                    public String format(Object... args)
-                    {
-                        return String.format("%2$s must be at most %1$s", args);
-                    }
-
-                } : null;
-            }
-
-        };
-        FieldValidator<Number> fv = new FieldValidatorImpl<Number>(field, messages, min, max);
-        fv.validate(10);
-        fv.validate(11);
-        fv.validate(12);
-        try
-        {
-            fv.validate(13);
-            unreachable();
-        }
-        catch (ValidationException ex)
-        {
-            assertEquals(ex.getMessage(), "foo must be at most 12");
-        }
-        FieldValidator<Number> fv2 = new FieldValidatorImpl<Number>(field, messages, max, min);
-        fv2.validate(10);
-        fv2.validate(11);
-        fv2.validate(12);
-        try
-        {
-            fv2.validate(13);
-            unreachable();
-        }
-        catch (ValidationException ex)
-        {
-            assertEquals(ex.getMessage(), "foo must be at most 12");
-        }
+        fv.validate(value);
+
+        verify();
     }
 
+    @SuppressWarnings("unchecked")
     @Test
-    public void null_validators() throws Exception
+    public void value_type_check_skipped_for_null_values() throws Exception
     {
-        final Field field = new NoOpField()
-        {
+        Field field = newField();
+        MessageFormatter formatter = newMessageFormatter();
+        Validator validator = newValidator();
 
-            @Override
-            public String getLabel()
-            {
-                return "foo";
-            }
-
-        };
-        FieldValidatorMessages messages = new FieldValidatorMessages()
-        {
-            public MessageFormatter get(Field field2, Validator validator)
-            {
-                return null;
-            }
-
-        };
-        FieldValidator<Number> fv = new FieldValidatorImpl<Number>(field, messages,
-                (Validator<? super Number>[]) null);
-        fv.validate(10);
-        fv.validate(11);
-    }
+        train_invokeIfBlank(validator, true);
+
+        validator.validate(field, null, formatter, null);
+
+        replay();
 
+        FieldValidator fv = new FieldValidatorImpl(field, null, formatter, validator);
+
+        fv.validate(null);
+
+        verify();
+    }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/validator/MaxLengthTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/validator/MaxLengthTest.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/validator/MaxLengthTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/validator/MaxLengthTest.java Sun Feb  4 08:07:30 2007
@@ -16,7 +16,6 @@
 
 import org.apache.tapestry.Field;
 import org.apache.tapestry.ValidationException;
-import org.apache.tapestry.internal.services.NoOpField;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.MessageFormatter;
 import org.testng.annotations.Test;
@@ -32,9 +31,9 @@
 
         replay();
 
-        MaxLength validator = new MaxLength(value.length());
+        MaxLength validator = new MaxLength();
 
-        validator.validate(field, formatter, value);
+        validator.validate(field, value.length(), formatter, value);
 
         verify();
     }
@@ -42,35 +41,29 @@
     @Test
     public void long_value() throws Exception
     {
-        Field field = new NoOpField()
-        {
-        
-            @Override
-            public String getLabel()
-            {
-                return "foo";
-            }
-        
-        }; 
-        MessageFormatter formatter = new MessageFormatter()
-        {
-        
-            public String format(Object... args)
-            {
-                return String.format("aaa %1$s %2$s bbb", args);
-            }
-        
-        };
-        MaxLength validator = new MaxLength(5);
+        String label = "My Field";
+        Field field = newFieldWithLabel(label);
+        MessageFormatter formatter = newMessageFormatter();
+        String value = "Now the student has become the master.";
+        String message = "{message}";
+        Integer constraint = value.length() - 1;
+
+        train_format(formatter, message, constraint, label);
+
+        replay();
+
+        MaxLength validator = new MaxLength();
 
         try
         {
-            validator.validate(field, formatter, "abcdef");
+            validator.validate(field, constraint, formatter, value);
             unreachable();
         }
         catch (ValidationException ex)
         {
-            assertEquals(ex.getMessage(), "aaa 5 foo bbb");
+            assertEquals(ex.getMessage(), message);
         }
+
+        verify();
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/validator/MinLengthTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/validator/MinLengthTest.java?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/validator/MinLengthTest.java (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/validator/MinLengthTest.java Sun Feb  4 08:07:30 2007
@@ -16,7 +16,6 @@
 
 import org.apache.tapestry.Field;
 import org.apache.tapestry.ValidationException;
-import org.apache.tapestry.internal.services.NoOpField;
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.ioc.MessageFormatter;
 import org.testng.annotations.Test;
@@ -33,9 +32,9 @@
 
         replay();
 
-        MinLength validator = new MinLength(value.length());
+        MinLength validator = new MinLength();
 
-        validator.validate(field, formatter, value);
+        validator.validate(field, value.length(), formatter, value);
 
         verify();
     }
@@ -43,35 +42,29 @@
     @Test
     public void short_value() throws Exception
     {
-        Field field = new NoOpField()
-        {
-        
-            @Override
-            public String getLabel()
-            {
-                return "foo";
-            }
-        
-        }; 
-        MessageFormatter formatter = new MessageFormatter()
-        {
-        
-            public String format(Object... args)
-            {
-                return String.format("aaa %1$s %2$s bbb", args);
-            }
-        
-        };
-        MinLength validator = new MinLength(5);
+        String label = "My Field";
+        Field field = newFieldWithLabel(label);
+        MessageFormatter formatter = newMessageFormatter();
+        String value = "Now the student has become the master.";
+        String message = "{message}";
+        Integer constraint = value.length() + 1;
+
+        train_format(formatter, message, constraint, label);
+
+        replay();
+
+        MinLength validator = new MinLength();
 
         try
         {
-            validator.validate(field, formatter, "abcd");
+            validator.validate(field, constraint, formatter, value);
             unreachable();
         }
         catch (ValidationException ex)
         {
-            assertEquals(ex.getMessage(), "aaa 5 foo bbb");
+            assertEquals(ex.getMessage(), message);
         }
+
+        verify();
     }
 }

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app1/pages/ValidForm.html Sun Feb  4 08:07:30 2007
@@ -8,17 +8,17 @@
         <t:comp type="Errors"/>
         
         <label t:type="Label"  for="email">This isn't used</label>: <input
-            t:id="email" size="50"/>
+            t:type="TextField" t:id="email" value="incident.email" size="50" t:validate="required"/>
         <br/>
-        <label t:type="Label"  for="message"/>: <textarea t:id="message"
-            cols="50" rows="10"> You can put text here, but it isn't used. </textarea>
+        <label t:type="Label"  for="message"/>: <textarea t:type="TextArea" t:id="message" t:label="Incident Message"
+            value="incident.message" cols="50" rows="10"> You can put text here, but it isn't used. </textarea>
         <br/>
-        <input t:id="urgent" />
+        <input t:type="Checkbox" t:id="urgent" value="incident.urgent"/>
         <label t:type="Label" for="urgent"/>
         <br/>
         
         <label t:type="Label" for="hours"/>:
-        <input t:id="hours" size="10"/>
+        <input t:type="TextField" t:id="hours" value="incident.hours" size="10" t:validate="required"/>
         
         <br/>
         

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForForm.html Sun Feb  4 08:07:30 2007
@@ -1,6 +1,6 @@
 <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
 <p><t:comp id="form1" type="Form">
-	<t:comp id="t1" size="50"/>
+	<t:comp type="TextField" id="t1" value="value" size="50"/>
 </t:comp></p>
 <p>
 	You entered: ${value}.

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForSubmit.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForSubmit.html?view=diff&rev=503433&r1=503432&r2=503433
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForSubmit.html (original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/resources/org/apache/tapestry/integration/app2/pages/TestPageForSubmit.html Sun Feb  4 08:07:30 2007
@@ -1,12 +1,12 @@
 <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
 <p>
 <form t:id="form1">
-	<t:comp id="t1"/>
+	<t:comp id="t1" type="TextField"/>
 	<t:comp id="capitalize1"/>
 </form>	
 <form t:id="form2">
 	<t:comp id="capitalize2"/>
-	<t:comp id="t2"/>
+	<t:comp id="t2" type="TextField"/>
 </form></p>
 <input type="submit" id="orphanedSubmit"/>
 <p>



Mime
View raw message