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 2011/02/10 22:14:03 UTC

svn commit: r1069569 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry5/ main/java/org/apache/tapestry5/internal/services/ main/java/org/apache/tapestry5/services/ main/java/org/apache/tapestry5/test/ test/java/org/apache/...

Author: hlship
Date: Thu Feb 10 21:13:58 2011
New Revision: 1069569

URL: http://svn.apache.org/viewvc?rev=1069569&view=rev
Log:
TAP5-1441: Remove ValidationMessagesSource, replaced with ComponentMessagesSource

Removed:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ValidationMessagesSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/ValidationMessagesSource.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/ValidationMessagesSourceImplTest.java
Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Translator.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Validator.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldTranslatorSource.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldValidatorSource.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/MarkupRendererFilter.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PartialMarkupRendererFilter.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImplTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidationSupportImplTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImplTest.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Translator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Translator.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Translator.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Translator.java Thu Feb 10 21:13:58 2011
@@ -1,10 +1,10 @@
-// Copyright 2006, 2008 The Apache Software Foundation
+// Copyright 2006, 2008, 2011 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
+// 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,
@@ -18,7 +18,7 @@ import org.apache.tapestry5.services.For
 
 /**
  * Translates between client-side and server-side values. Client-side values are always strings.
- *
+ * 
  * @param <T>
  * @see org.apache.tapestry5.services.TranslatorSource
  * @see org.apache.tapestry5.FieldValidationSupport
@@ -29,59 +29,66 @@ public interface Translator<T>
     /**
      * Returns a unique name for the translator. This is used to identify the translator by name, but is also used when
      * locating override messages for the translator.
-     *
+     * 
      * @return unique name for the translator
      */
     String getName();
 
     /**
      * Converts a server-side value to a client-side string. This allows for formatting of the value in a way
-     * appropriate to the end user. The output client value should be parsable by {@link #parseClient(Field, String,
-     * String)}.
-     *
-     * @param value the server side value (which will not be null)
+     * appropriate to the end user. The output client value should be parsable by
+     * {@link #parseClient(Field, String, String)}.
+     * 
+     * @param value
+     *            the server side value (which will not be null)
      * @return client-side value to present to the user
      */
     String toClient(T value);
 
     /**
-     * Returns the type of  the server-side value.
-     *
+     * Returns the type of the server-side value.
+     * 
      * @return a type
      */
     Class<T> getType();
 
     /**
-     * Returns the message key, within the validation messages, normally used by this validator. This is used to provide
-     * the formatted message to {@link #parseClient(Field, String, String)} or {@link #render(Field, String,
-     * MarkupWriter, org.apache.tapestry5.services.FormSupport)}.
-     *
+     * Returns the message key, within the application's global message catalog, normally used by this validator. This
+     * is used to provide the formatted message to {@link #parseClient(Field, String, String)} or
+     * {@link #render(Field, String, MarkupWriter, org.apache.tapestry5.services.FormSupport)}.
+     * 
      * @return a message key
-     * @see org.apache.tapestry5.services.ValidationMessagesSource
      */
     String getMessageKey();
 
     /**
      * Converts a submitted request value into an appropriate server side value.
-     *
-     * @param field       for which a value is being parsed
-     * @param clientValue to convert to a server value; this will not be null, but may be blank
-     * @param message     formatted validation message, either from validation messages, or from an override
+     * 
+     * @param field
+     *            for which a value is being parsed
+     * @param clientValue
+     *            to convert to a server value; this will not be null, but may be blank
+     * @param message
+     *            formatted validation message, either from validation messages, or from an override
      * @return equivalent server-side value (possibly null)
-     * @throws ValidationException if the value can not be parsed
+     * @throws ValidationException
+     *             if the value can not be parsed
      */
     T parseClient(Field field, String clientValue, String message) throws ValidationException;
 
     /**
      * Hook used by components to allow the validator to contribute additional attributes or (more often) client-side
-     * JavaScript (via the {@link org.apache.tapestry5.services.FormSupport#addValidation(Field, String, String,
-     * Object)}).
-     *
-     * @param field       the field which is currently being rendered
-     * @param message     formatted validation message, either from validation messages, or from an override
-     * @param writer      markup writer, allowing additional attributes to be written into the active element
-     * @param formSupport used to add JavaScript
+     * JavaScript (via the
+     * {@link org.apache.tapestry5.services.FormSupport#addValidation(Field, String, String, Object)}).
+     * 
+     * @param field
+     *            the field which is currently being rendered
+     * @param message
+     *            formatted validation message, either from validation messages, or from an override
+     * @param writer
+     *            markup writer, allowing additional attributes to be written into the active element
+     * @param formSupport
+     *            used to add JavaScript
      */
-    void render(Field field, String message, MarkupWriter writer,
-                FormSupport formSupport);
+    void render(Field field, String message, MarkupWriter writer, FormSupport formSupport);
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Validator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Validator.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Validator.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/Validator.java Thu Feb 10 21:13:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2011 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.
@@ -47,7 +47,6 @@ public interface Validator<C, T>
      * overridden).
      *
      * @return a message key
-     * @see org.apache.tapestry5.services.ValidationMessagesSource
      */
     String getMessageKey();
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImpl.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImpl.java Thu Feb 10 21:13:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2008, 2010 The Apache Software Foundation
+// Copyright 2008, 2010, 2011 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.
@@ -28,22 +28,21 @@ import org.apache.tapestry5.ioc.internal
 import org.apache.tapestry5.services.FieldTranslatorSource;
 import org.apache.tapestry5.services.FormSupport;
 import org.apache.tapestry5.services.TranslatorSource;
-import org.apache.tapestry5.services.ValidationMessagesSource;
 
 @SuppressWarnings("all")
 public class FieldTranslatorSourceImpl implements FieldTranslatorSource
 {
     private final TranslatorSource translatorSource;
 
-    private final ValidationMessagesSource validationMessagesSource;
+    private final Messages globalMessages;
 
     private final FormSupport formSupport;
 
-    public FieldTranslatorSourceImpl(TranslatorSource translatorSource,
-            ValidationMessagesSource validationMessagesSource, FormSupport formSupport)
+    public FieldTranslatorSourceImpl(TranslatorSource translatorSource, Messages globalMessages,
+            FormSupport formSupport)
     {
         this.translatorSource = translatorSource;
-        this.validationMessagesSource = validationMessagesSource;
+        this.globalMessages = globalMessages;
         this.formSupport = formSupport;
     }
 
@@ -54,8 +53,8 @@ public class FieldTranslatorSourceImpl i
         Field field = (Field) resources.getComponent();
         Class propertyType = resources.getBoundType(parameterName);
 
-        return createDefaultTranslator(field, resources.getId(), resources.getContainerMessages(), resources
-                .getLocale(), propertyType, resources.getAnnotationProvider(parameterName));
+        return createDefaultTranslator(field, resources.getId(), resources.getContainerMessages(),
+                null, propertyType, resources.getAnnotationProvider(parameterName));
     }
 
     public FieldTranslator createDefaultTranslator(Field field, String overrideId, Messages overrideMessages,
@@ -63,7 +62,6 @@ public class FieldTranslatorSourceImpl i
     {
         assert field != null;
         assert overrideMessages != null;
-        assert locale != null;
         assert InternalUtils.isNonBlank(overrideId);
         if (propertyType == null)
             return null;
@@ -92,7 +90,7 @@ public class FieldTranslatorSourceImpl i
     public FieldTranslator createTranslator(Field field, String overrideId, Messages overrideMessages, Locale locale,
             Translator translator)
     {
-        MessageFormatter formatter = findFormatter(overrideId, overrideMessages, locale, translator);
+        MessageFormatter formatter = findFormatter(overrideId, overrideMessages, translator);
 
         return new FieldTranslatorImpl(field, translator, formatter, formSupport);
     }
@@ -105,12 +103,10 @@ public class FieldTranslatorSourceImpl i
 
         Translator translator = translatorSource.get(translatorName);
 
-        return createTranslator(field, resources.getId(), resources.getContainerMessages(), resources.getLocale(),
-                translator);
+        return createTranslator(field, resources.getId(), resources.getContainerMessages(), null, translator);
     }
 
-    private MessageFormatter findFormatter(String overrideId, Messages overrideMessages, Locale locale,
-            Translator translator)
+    private MessageFormatter findFormatter(String overrideId, Messages overrideMessages, Translator translator)
     {
         // TAP5-228: Try to distinguish message overrides by form id and overrideId (i.e., property name) first.
 
@@ -130,8 +126,6 @@ public class FieldTranslatorSourceImpl i
 
         // Otherwise, use the built-in validation message appropriate to this validator.
 
-        Messages validationMessages = validationMessagesSource.getValidationMessages(locale);
-
-        return validationMessages.getFormatter(translator.getMessageKey());
+        return globalMessages.getFormatter(translator.getMessageKey());
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImpl.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImpl.java Thu Feb 10 21:13:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2010, 2011 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.
@@ -32,13 +32,12 @@ import org.apache.tapestry5.ioc.services
 import org.apache.tapestry5.runtime.Component;
 import org.apache.tapestry5.services.FieldValidatorSource;
 import org.apache.tapestry5.services.FormSupport;
-import org.apache.tapestry5.services.ValidationMessagesSource;
 import org.apache.tapestry5.validator.ValidatorMacro;
 
 @SuppressWarnings("all")
 public class FieldValidatorSourceImpl implements FieldValidatorSource
 {
-    private final ValidationMessagesSource messagesSource;
+    private final Messages globalMessages;
 
     private final Map<String, Validator> validators;
 
@@ -48,10 +47,10 @@ public class FieldValidatorSourceImpl im
 
     private final ValidatorMacro validatorMacro;
 
-    public FieldValidatorSourceImpl(ValidationMessagesSource messagesSource, TypeCoercer typeCoercer,
+    public FieldValidatorSourceImpl(Messages globalMessages, TypeCoercer typeCoercer,
             FormSupport formSupport, Map<String, Validator> validators, ValidatorMacro validatorMacro)
     {
-        this.messagesSource = messagesSource;
+        this.globalMessages = globalMessages;
         this.typeCoercer = typeCoercer;
         this.formSupport = formSupport;
         this.validators = validators;
@@ -60,49 +59,49 @@ public class FieldValidatorSourceImpl im
 
     public FieldValidator createValidator(Field field, String validatorType, String constraintValue)
     {
-        Component component = (Component) field;        
+        Component component = (Component) field;
         assert InternalUtils.isNonBlank(validatorType);
         ComponentResources componentResources = component.getComponentResources();
         String overrideId = componentResources.getId();
-        Locale locale = componentResources.getLocale();
 
         // So, if you use a TextField on your EditUser page, we want to search the messages
         // of the EditUser page (the container), not the TextField (which will always be the same).
 
         Messages overrideMessages = componentResources.getContainerMessages();
 
-        return createValidator(field, validatorType, constraintValue, overrideId, overrideMessages, locale);
+        return createValidator(field, validatorType, constraintValue, overrideId, overrideMessages, null);
     }
 
     public FieldValidator createValidator(Field field, String validatorType, String constraintValue, String overrideId,
             Messages overrideMessages, Locale locale)
     {
-    	
-    	ValidatorSpecification originalSpec = new ValidatorSpecification(validatorType, constraintValue);
-    	
-    	List<ValidatorSpecification> specs = expandMacros(newList(originalSpec));
-    	
-    	List<FieldValidator> fieldValidators = CollectionFactory.newList();
-    	
-    	for (ValidatorSpecification spec : specs) {
-			fieldValidators.add(createValidator(field, spec, overrideId, overrideMessages, locale));
-		}
-    	
-    	return new CompositeFieldValidator(fieldValidators);
+
+        ValidatorSpecification originalSpec = new ValidatorSpecification(validatorType, constraintValue);
+
+        List<ValidatorSpecification> specs = expandMacros(newList(originalSpec));
+
+        List<FieldValidator> fieldValidators = CollectionFactory.newList();
+
+        for (ValidatorSpecification spec : specs)
+        {
+            fieldValidators.add(createValidator(field, spec, overrideId, overrideMessages));
+        }
+
+        return new CompositeFieldValidator(fieldValidators);
     }
-    
+
     private FieldValidator createValidator(Field field, ValidatorSpecification spec, String overrideId,
-            Messages overrideMessages, Locale locale)
+            Messages overrideMessages)
     {
-    	
-    	String validatorType = spec.getValidatorType();
-    	
+
+        String validatorType = spec.getValidatorType();
+
         assert InternalUtils.isNonBlank(validatorType);
         Validator validator = validators.get(validatorType);
 
         if (validator == null)
-            throw new IllegalArgumentException(ServicesMessages.unknownValidatorType(validatorType, InternalUtils
-                    .sortedKeys(validators)));
+            throw new IllegalArgumentException(ServicesMessages.unknownValidatorType(validatorType,
+                    InternalUtils.sortedKeys(validators)));
 
         // I just have this thing about always treating parameters as finals, so
         // we introduce a second variable to treat a mutable.
@@ -112,8 +111,8 @@ public class FieldValidatorSourceImpl im
         Object coercedConstraintValue = computeConstraintValue(validatorType, validator, spec.getConstraintValue(),
                 formValidationid, overrideId, overrideMessages);
 
-        MessageFormatter formatter = findMessageFormatter(formValidationid, overrideId, overrideMessages, locale,
-                validatorType, validator);
+        MessageFormatter formatter = findMessageFormatter(formValidationid, overrideId, overrideMessages, validatorType,
+                validator);
 
         return new FieldValidatorImpl(field, coercedConstraintValue, formatter, validator, formSupport);
     }
@@ -159,7 +158,7 @@ public class FieldValidatorSourceImpl im
     }
 
     private MessageFormatter findMessageFormatter(String formId, String overrideId, Messages overrideMessages,
-            Locale locale, String validatorType, Validator validator)
+            String validatorType, Validator validator)
     {
 
         String overrideKey = formId + "-" + overrideId + "-" + validatorType + "-message";
@@ -172,11 +171,9 @@ public class FieldValidatorSourceImpl im
         if (overrideMessages.contains(overrideKey))
             return overrideMessages.getFormatter(overrideKey);
 
-        Messages messages = messagesSource.getValidationMessages(locale);
-
         String key = validator.getMessageKey();
 
-        return messages.getFormatter(key);
+        return globalMessages.getFormatter(key);
     }
 
     public FieldValidator createValidators(Field field, String specification)

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldTranslatorSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldTranslatorSource.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldTranslatorSource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldTranslatorSource.java Thu Feb 10 21:13:58 2011
@@ -1,4 +1,4 @@
-//  Copyright 2008 The Apache Software Foundation
+//  Copyright 2008, 2011 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.
@@ -47,7 +47,7 @@ public interface FieldTranslatorSource
      * @param field               for which a translator is needed
      * @param overrideId          id used when looking in the overrideMessages for a message override
      * @param overrideMessages    location to look for overriding messages
-     * @param locale              to localize validation messages to
+     * @param locale              no longer used in 5.3, may be null
      * @param propertyType        type of property editted by the field, used to select the Translator
      * @param propertyAnnotations annotations on the property (not currently used)
      * @return the field translator, or null
@@ -57,6 +57,7 @@ public interface FieldTranslatorSource
 
     /**
      * Wraps a {@link org.apache.tapestry5.Translator} as a FieldTranslator.
+     * @param locale no longer used in 5.3, may be null
      */
     FieldTranslator createTranslator(Field field, String overrideId, Messages overrideMessages, Locale locale,
                                      Translator translator);

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldValidatorSource.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldValidatorSource.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldValidatorSource.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/FieldValidatorSource.java Thu Feb 10 21:13:58 2011
@@ -1,10 +1,10 @@
-// Copyright 2006, 2008 The Apache Software Foundation
+// Copyright 2006, 2008, 2011 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
+// 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,
@@ -31,16 +31,19 @@ import java.util.Locale;
 public interface FieldValidatorSource
 {
     /**
-     * Creates the validator. The error message associated with the field validator usually comes from the {@link
-     * ValidationMessagesSource} (using the validator's {@link Validator#getMessageKey() message key}). However, if the
-     * container component of the field defines a message key <code><i>id</i>-<i>validator</i> (where id is the simple
+     * Creates the validator. The error message associated with the field validator usually comes from the
+     * global message catalog (using the validator's {@link Validator#getMessageKey() message key}). However,
+     * if the container component of the field defines a message key <code><i>id</i>-<i>validator</i> (where id is the simple
      * id of the field component, and validator is the validatorType), then that message is used instead. This allows
      * you to override the message for a particular validation of a particular field.
-     *
-     * @param field           the field for which a validator is to be created
-     * @param validatorType   used to select the {@link org.apache.tapestry5.Validator} that forms the core of the
-     *                        {@link org.apache.tapestry5.FieldValidator}
-     * @param constraintValue a value used to configure the validator, or null if the validator is not configurarable
+     * 
+     * @param field
+     *            the field for which a validator is to be created
+     * @param validatorType
+     *            used to select the {@link org.apache.tapestry5.Validator} that forms the core of the
+     *            {@link org.apache.tapestry5.FieldValidator}
+     * @param constraintValue
+     *            a value used to configure the validator, or null if the validator is not configurarable
      * @return the field validator for the field
      */
     FieldValidator createValidator(Field field, String validatorType, String constraintValue);
@@ -49,27 +52,32 @@ public interface FieldValidatorSource
      * 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 BeanEditForm} is an example of this.
-     *
-     * @param field            the field for which a validator is to be created
-     * @param validatorType    used to select the {@link org.apache.tapestry5.Validator} that forms the core of the
-     *                         {@link org.apache.tapestry5.FieldValidator}
-     * @param constraintValue  a value used to configure the validator, or null if the validator is not configurable
-     * @param overrideId       the base id used when searching for validator message overrides (this would normally be
-     *                         the field component's simple id)
-     * @param overrideMessages the message catalog to search for override messages (this would normally be the catalog
-     *                         for the container of the field component)
-     * @param locale           locale used when retrieving default validation messages from the {@link
-     *                         org.apache.tapestry5.services.ValidationMessagesSource}
+     * 
+     * @param field
+     *            the field for which a validator is to be created
+     * @param validatorType
+     *            used to select the {@link org.apache.tapestry5.Validator} that forms the core of the
+     *            {@link org.apache.tapestry5.FieldValidator}
+     * @param constraintValue
+     *            a value used to configure the validator, or null if the validator is not configurable
+     * @param overrideId
+     *            the base id used when searching for validator message overrides (this would normally be
+     *            the field component's simple id)
+     * @param overrideMessages
+     *            the message catalog to search for override messages (this would normally be the catalog
+     *            for the container of the field component)
+     * @param locale
+     *            ignored, starting in 5.3 (it is allowed to pass null). Locale was needed in release 5.2 and earlier.
      * @return the field validator for the field
      */
-    FieldValidator createValidator(Field field, String validatorType, String constraintValue,
-                                   String overrideId, Messages overrideMessages, Locale locale);
+    FieldValidator createValidator(Field field, String validatorType, String constraintValue, String overrideId,
+            Messages overrideMessages, Locale locale);
 
     /**
      * Creates a set of validators. The specification is a string used to identify and configure the individual
      * validators. The specification is a comma-separated list of terms. Each term is a validator type name and an
      * optional constraint value (seperated by an equals sign).
-     *
+     * 
      * @param field
      * @param specification
      * @return a composite field validator

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/MarkupRendererFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/MarkupRendererFilter.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/MarkupRendererFilter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/MarkupRendererFilter.java Thu Feb 10 21:13:58 2011
@@ -1,10 +1,10 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2011 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
+// 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,
@@ -18,20 +18,23 @@ import org.apache.tapestry5.MarkupWriter
 
 /**
  * Filter interface for {@link org.apache.tapestry5.services.MarkupRenderer}, which allows for code to execute before
- * and/or after the main rendering process.  Typically, this is to allow for the placement of {@linkplain
- * org.apache.tapestry5.services.Environment environmental services}.
- *
+ * and/or after the main rendering process. Typically, this is to allow for the placement of
+ * {@linkplain org.apache.tapestry5.services.Environment environmental services}.
+ * 
  * @see org.apache.tapestry5.services.TapestryModule#contributeMarkupRenderer(org.apache.tapestry5.ioc.OrderedConfiguration,
- *      org.apache.tapestry5.Asset, org.apache.tapestry5.Asset, ValidationMessagesSource,
- *      org.apache.tapestry5.ioc.services.SymbolSource, AssetSource)
+ *      org.apache.tapestry5.Asset, boolean, String, boolean, org.apache.tapestry5.ioc.services.SymbolSource,
+ *      AssetSource, org.apache.tapestry5.services.javascript.JavaScriptStackSource,
+ *      org.apache.tapestry5.internal.services.javascript.JavaScriptStackPathConstructor, org.apache.tapestry5.Asset)
  */
 public interface MarkupRendererFilter
 {
     /**
      * Implementations should perform work before or after passing the writer to the renderer.
-     *
-     * @param writer   to which markup should be written
-     * @param renderer delegate to which the writer should be passed.
+     * 
+     * @param writer
+     *            to which markup should be written
+     * @param renderer
+     *            delegate to which the writer should be passed.
      */
     void renderMarkup(MarkupWriter writer, MarkupRenderer renderer);
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PartialMarkupRendererFilter.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PartialMarkupRendererFilter.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PartialMarkupRendererFilter.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/PartialMarkupRendererFilter.java Thu Feb 10 21:13:58 2011
@@ -1,10 +1,10 @@
-// Copyright 2007 The Apache Software Foundation
+// Copyright 2007, 2011 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
+// 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,
@@ -19,22 +19,26 @@ import org.apache.tapestry5.json.JSONObj
 
 /**
  * A filter (the main interface being {@link PartialMarkupRenderer}) applied when performing a partial page render as
- * part of an Ajax-oriented request.  This is similar to {@link org.apache.tapestry5.services.MarkupRendererFilter} and
+ * part of an Ajax-oriented request. This is similar to {@link org.apache.tapestry5.services.MarkupRendererFilter} and
  * filters are often in place so as to contribute {@link org.apache.tapestry5.annotations.Environmental} services to the
  * pages and components that render.
- *
+ * 
  * @see org.apache.tapestry5.services.TapestryModule#contributePartialMarkupRenderer(org.apache.tapestry5.ioc.OrderedConfiguration,
- *      org.apache.tapestry5.Asset, org.apache.tapestry5.ioc.services.SymbolSource, AssetSource,
- *      ValidationMessagesSource)
+ *      org.apache.tapestry5.Asset, org.apache.tapestry5.services.javascript.JavaScriptStackSource,
+ *      org.apache.tapestry5.internal.services.javascript.JavaScriptStackPathConstructor,
+ *      org.apache.tapestry5.ioc.services.SymbolSource, AssetSource)
  */
 public interface PartialMarkupRendererFilter
 {
     /**
      * Implementations should perform work before or after passing the writer to the renderer.
-     *
-     * @param writer   to which markup should be written
-     * @param reply    JSONObject which will contain the partial response
-     * @param renderer delegate to which the writer should be passed
+     * 
+     * @param writer
+     *            to which markup should be written
+     * @param reply
+     *            JSONObject which will contain the partial response
+     * @param renderer
+     *            delegate to which the writer should be passed
      */
     void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer);
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/services/TapestryModule.java Thu Feb 10 21:13:58 2011
@@ -1387,32 +1387,6 @@ public final class TapestryModule
         return chainBuilder.build(BindingFactory.class, configuration);
     }
 
-    /**
-     * Builds the source of {@link Messages} containing validation messages. The
-     * contributions are paths to message
-     * bundles (resource paths within the classpath); the default contribution
-     * is "org/apache/tapestry5/internal/ValidationMessages".
-     */
-    public ValidationMessagesSource buildValidationMessagesSource(List<String> configuration,
-
-    UpdateListenerHub updateListenerHub,
-
-    @ClasspathProvider
-    AssetFactory classpathAssetFactory,
-
-    PropertiesFileParser parser,
-
-    ComponentMessagesSource componentMessagesSource,
-
-    ClasspathURLConverter classpathURLConverter)
-    {
-        ValidationMessagesSourceImpl service = new ValidationMessagesSourceImpl(configuration,
-                classpathAssetFactory.getRootResource(), parser, componentMessagesSource, classpathURLConverter);
-        updateListenerHub.addUpdateListener(service);
-
-        return service;
-    }
-
     public static MetaDataLocator buildMetaDataLocator(@Autobuild
     MetaDataLocatorImpl service, @ComponentClasses
     InvalidationEventHub hub)
@@ -2330,15 +2304,6 @@ public final class TapestryModule
         configuration.add(PersistenceConstants.CLIENT, clientStrategy);
     }
 
-    /**
-     * Contributes org/apache/tapestry5/internal/ValidationMessages as
-     * "Default", ordered first.
-     */
-    public void contributeValidationMessagesSource(OrderedConfiguration<String> configuration)
-    {
-        configuration.add("Default", "org/apache/tapestry5/internal/ValidationMessages", "before:*");
-    }
-
     @SuppressWarnings("rawtypes")
     public static ValueEncoderSource buildValueEncoderSource(Map<Class, ValueEncoderFactory> configuration,
             @ComponentClasses
@@ -2532,7 +2497,7 @@ public final class TapestryModule
         configuration.add(InternalSymbols.PRE_SELECTED_FORM_NAMES, "reset,submit,select,id,method,action,onsubmit");
 
         configuration.add(SymbolConstants.COMPONENT_RENDER_TRACING_ENABLED, "false");
-        
+
         // The default values denote "use values from request"
         configuration.add(SymbolConstants.HOSTNAME, "");
         configuration.add(SymbolConstants.HOSTPORT, "0");
@@ -2972,13 +2937,23 @@ public final class TapestryModule
     }
 
     /**
-     * Contributes "AppCatalog" as the Resource defined by {@link SymbolConstants#APPLICATION_CATALOG}.
+     * Contributes:
+     * <dl>
+     * <dt>AppCatalog</dt>
+     * <dd>The Resource defined by {@link SymbolConstants#APPLICATION_CATALOG}</dd>
+     * <dt>ValidationMessages</dt>
+     * <dd>Messages used by validators (before:AppCatalog)</dd>
+     * <dt>
      * 
      * @since 5.2.0
      */
-    public static void contributeComponentMessagesSource(@Symbol(SymbolConstants.APPLICATION_CATALOG)
-    Resource applicationCatalog, OrderedConfiguration<Resource> configuration)
-    {
+    public static void contributeComponentMessagesSource(AssetSource assetSource,
+            @Symbol(SymbolConstants.APPLICATION_CATALOG)
+            Resource applicationCatalog, OrderedConfiguration<Resource> configuration)
+    {
+        configuration.add("ValidationMessages",
+                assetSource.resourceForPath("org/apache/tapestry5/internal/ValidationMessages.properties"),
+                "before:AppCatalog");
         configuration.add("AppCatalog", applicationCatalog);
     }
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/test/TapestryTestCase.java Thu Feb 10 21:13:58 2011
@@ -295,12 +295,6 @@ public abstract class TapestryTestCase e
         return newMock(ValidationConstraintGenerator.class);
     }
 
-    /** @deprecated May be removed in Tapestry 5.3 */
-    protected final ValidationMessagesSource mockValidationMessagesSource()
-    {
-        return newMock(ValidationMessagesSource.class);
-    }
-
     protected final ValidationTracker mockValidationTracker()
     {
         return newMock(ValidationTracker.class);
@@ -683,13 +677,6 @@ public abstract class TapestryTestCase e
         expect(model.getSupportsInformalParameters()).andReturn(supports).atLeastOnce();
     }
 
-    /** @deprecated May be removed in Tapestry 5.3 */
-    protected final void train_getValidationMessages(ValidationMessagesSource messagesSource, Locale locale,
-            Messages messages)
-    {
-        expect(messagesSource.getValidationMessages(locale)).andReturn(messages).atLeastOnce();
-    }
-
     protected final void train_getValueType(Validator validator, Class valueType)
     {
         expect(validator.getValueType()).andReturn(valueType).atLeastOnce();

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImplTest.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldTranslatorSourceImplTest.java Thu Feb 10 21:13:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2008, 2010 The Apache Software Foundation
+// Copyright 2008, 2010, 2011 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.
@@ -14,7 +14,14 @@
 
 package org.apache.tapestry5.internal.services;
 
-import org.apache.tapestry5.*;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.Field;
+import org.apache.tapestry5.FieldTranslator;
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.Translator;
 import org.apache.tapestry5.beaneditor.Translate;
 import org.apache.tapestry5.internal.test.InternalBaseTestCase;
 import org.apache.tapestry5.ioc.AnnotationProvider;
@@ -24,12 +31,8 @@ import org.apache.tapestry5.root.FieldCo
 import org.apache.tapestry5.services.FieldTranslatorSource;
 import org.apache.tapestry5.services.FormSupport;
 import org.apache.tapestry5.services.TranslatorSource;
-import org.apache.tapestry5.services.ValidationMessagesSource;
 import org.testng.annotations.Test;
 
-import java.util.Locale;
-import java.util.Map;
-
 /**
  * Fills in some gaps that are not currently tested by the integration tests.
  */
@@ -117,10 +120,9 @@ public class FieldTranslatorSourceImplTe
         Locale locale = Locale.ENGLISH;
         Class propertyType = Map.class;
         TranslatorSource ts = mockTranslatorSource();
-        ValidationMessagesSource vms = mockValidationMessagesSource();
         FormSupport fs = mockFormSupport();
         Translator translator = mockTranslator("maptrans", Map.class);
-        Messages validationMessages = mockMessages();
+        Messages globalMessages = mockMessages();
         MessageFormatter formatter = mockMessageFormatter();
         MarkupWriter writer = mockMarkupWriter();
         String label = "Field Label";
@@ -133,10 +135,8 @@ public class FieldTranslatorSourceImplTe
 
         train_contains(messages, "myform-myfield-maptrans-message", false);
         train_contains(messages, "myfield-maptrans-message", false);
-        train_getValidationMessages(vms, locale, validationMessages);
-
         train_getMessageKey(translator, "mykey");
-        train_getMessageFormatter(validationMessages, "mykey", formatter);
+        train_getMessageFormatter(globalMessages, "mykey", formatter);
         train_getLabel(field, label);
         train_format(formatter, message, label);
 
@@ -144,7 +144,7 @@ public class FieldTranslatorSourceImplTe
 
         replay();
 
-        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, vms, fs);
+        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, globalMessages, fs);
 
         FieldTranslator ft = source.createDefaultTranslator(field, "myfield", messages, locale, propertyType, ap);
 
@@ -163,7 +163,6 @@ public class FieldTranslatorSourceImplTe
         Locale locale = Locale.ENGLISH;
         Class propertyType = Map.class;
         TranslatorSource ts = mockTranslatorSource();
-        ValidationMessagesSource vms = mockValidationMessagesSource();
         FormSupport fs = mockFormSupport();
         Translator translator = mockTranslator("maptrans", Map.class);
         MessageFormatter formatter = mockMessageFormatter();
@@ -187,7 +186,7 @@ public class FieldTranslatorSourceImplTe
 
         replay();
 
-        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, vms, fs);
+        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, null, fs);
 
         FieldTranslator ft = source.createDefaultTranslator(field, "myfield", messages, locale, propertyType, ap);
 
@@ -206,7 +205,6 @@ public class FieldTranslatorSourceImplTe
         Locale locale = Locale.ENGLISH;
         Class propertyType = Map.class;
         TranslatorSource ts = mockTranslatorSource();
-        ValidationMessagesSource vms = mockValidationMessagesSource();
         FormSupport fs = mockFormSupport();
         Translator translator = mockTranslator("maptrans", Map.class);
         MessageFormatter formatter = mockMessageFormatter();
@@ -229,7 +227,7 @@ public class FieldTranslatorSourceImplTe
 
         replay();
 
-        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, vms, fs);
+        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, null, fs);
 
         FieldTranslator ft = source.createDefaultTranslator(field, "myfield", messages, locale, propertyType, ap);
 
@@ -246,12 +244,10 @@ public class FieldTranslatorSourceImplTe
         ComponentResources resources = mockComponentResources();
         FieldComponent field = mockFieldComponent();
         Messages messages = mockMessages();
-        Locale locale = Locale.ENGLISH;
         TranslatorSource ts = mockTranslatorSource();
-        ValidationMessagesSource vms = mockValidationMessagesSource();
         FormSupport fs = mockFormSupport();
         Translator translator = mockTranslator("map", Map.class);
-        Messages validationMessages = mockMessages();
+        Messages globalMessages = mockMessages();
         MessageFormatter formatter = mockMessageFormatter();
         MarkupWriter writer = mockMarkupWriter();
         String label = "My Label";
@@ -260,7 +256,6 @@ public class FieldTranslatorSourceImplTe
         train_getComponent(resources, field);
         train_getId(resources, "myfield");
         train_getContainerMessages(resources, messages);
-        train_getLocale(resources, locale);
 
         train_get(ts, "map", translator);
 
@@ -268,10 +263,8 @@ public class FieldTranslatorSourceImplTe
 
         train_contains(messages, "myform-myfield-map-message", false);
         train_contains(messages, "myfield-map-message", false);
-        train_getValidationMessages(vms, locale, validationMessages);
-
         train_getMessageKey(translator, "mykey");
-        train_getMessageFormatter(validationMessages, "mykey", formatter);
+        train_getMessageFormatter(globalMessages, "mykey", formatter);
 
         train_getLabel(field, label);
         train_format(formatter, message, label);
@@ -280,7 +273,7 @@ public class FieldTranslatorSourceImplTe
 
         replay();
 
-        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, vms, fs);
+        FieldTranslatorSource source = new FieldTranslatorSourceImpl(ts, globalMessages, fs);
 
         FieldTranslator ft = source.createTranslator(resources, "map");
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidationSupportImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidationSupportImplTest.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidationSupportImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidationSupportImplTest.java Thu Feb 10 21:13:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2007, 2008 The Apache Software Foundation
+// Copyright 2007, 2008, 2011 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.
@@ -14,13 +14,20 @@
 
 package org.apache.tapestry5.internal.services;
 
-import org.apache.tapestry5.*;
+import static org.easymock.EasyMock.eq;
+
+import org.apache.tapestry5.ComponentEventCallback;
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.EventConstants;
+import org.apache.tapestry5.FieldTranslator;
+import org.apache.tapestry5.FieldValidationSupport;
+import org.apache.tapestry5.FieldValidator;
+import org.apache.tapestry5.NullFieldStrategy;
+import org.apache.tapestry5.ValidationException;
 import org.apache.tapestry5.corelib.internal.InternalMessages;
 import org.apache.tapestry5.internal.test.InternalBaseTestCase;
 import org.apache.tapestry5.ioc.services.TypeCoercer;
-import org.apache.tapestry5.services.ValidationMessagesSource;
 import org.easymock.EasyMock;
-import static org.easymock.EasyMock.eq;
 import org.easymock.IAnswer;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -193,7 +200,6 @@ public class FieldValidationSupportImplT
     {
         ComponentResources resources = mockComponentResources();
         FieldTranslator translator = mockFieldTranslator();
-        ValidationMessagesSource source = mockValidationMessagesSource();
         NullFieldStrategy nullFieldStrategy = mockNullFieldStrategy();
 
         String clientValue = "abracadabra";

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImplTest.java?rev=1069569&r1=1069568&r2=1069569&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/FieldValidatorSourceImplTest.java Thu Feb 10 21:13:58 2011
@@ -1,4 +1,4 @@
-// Copyright 2006, 2007, 2008, 2010 The Apache Software Foundation
+// Copyright 2006, 2007, 2008, 2010, 2011 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.
@@ -14,6 +14,14 @@
 
 package org.apache.tapestry5.internal.services;
 
+import static java.util.Collections.singletonMap;
+import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
 import org.apache.tapestry5.ComponentResources;
 import org.apache.tapestry5.Field;
 import org.apache.tapestry5.FieldValidator;
@@ -21,24 +29,14 @@ import org.apache.tapestry5.Validator;
 import org.apache.tapestry5.internal.test.InternalBaseTestCase;
 import org.apache.tapestry5.ioc.MessageFormatter;
 import org.apache.tapestry5.ioc.Messages;
-import static org.apache.tapestry5.ioc.internal.util.CollectionFactory.newMap;
-
-import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.services.TypeCoercer;
 import org.apache.tapestry5.runtime.Component;
 import org.apache.tapestry5.services.FieldValidatorSource;
 import org.apache.tapestry5.services.FormSupport;
-import org.apache.tapestry5.services.ValidationMessagesSource;
 import org.apache.tapestry5.validator.ValidatorMacro;
 import org.easymock.EasyMock;
 import org.testng.annotations.Test;
 
-import java.util.Arrays;
-import static java.util.Collections.singletonMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
 public class FieldValidatorSourceImplTest extends InternalBaseTestCase
 {
     public interface FieldComponent extends Field, Component
@@ -49,7 +47,6 @@ public class FieldValidatorSourceImplTes
     @Test
     public void unknown_validator_type()
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
@@ -60,9 +57,8 @@ public class FieldValidatorSourceImplTes
 
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
-        train_getLocale(resources, Locale.ENGLISH);
         train_getContainerMessages(resources, containerMessages);
-        
+
         train_alwaysNull(macro);
 
         map.put("alpha", validator);
@@ -70,7 +66,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, null, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(null, coercer, null, map, macro);
 
         try
         {
@@ -89,11 +85,10 @@ public class FieldValidatorSourceImplTes
     @Test
     public void validator_with_no_constraint() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
-        Messages messages = mockMessages();
+        Messages globalMessages = mockMessages();
         MessageFormatter formatter = mockMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = mockComponentResources();
@@ -108,22 +103,17 @@ public class FieldValidatorSourceImplTes
         train_getFormValidationId(fs, "form");
 
         train_getComponentResources(field, resources);
-        
 
         train_getId(resources, "fred");
         train_getContainerMessages(resources, containerMessages);
-        
+
         train_alwaysNull(macro);
-        
+
         train_contains(containerMessages, "form-fred-required-message", false);
         train_contains(containerMessages, "fred-required-message", false);
 
-        train_getLocale(resources, Locale.FRENCH);
-
-        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);
-
         train_getMessageKey(validator, "key");
-        train_getMessageFormatter(messages, "key", formatter);
+        train_getMessageFormatter(globalMessages, "key", formatter);
 
         train_isRequired(validator, false);
         train_getValueType(validator, Object.class);
@@ -131,7 +121,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(globalMessages, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidator(field, "required", null);
 
@@ -144,7 +134,6 @@ public class FieldValidatorSourceImplTes
     @Test
     public void component_messages_overrides_validator_messages() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
@@ -163,9 +152,8 @@ public class FieldValidatorSourceImplTes
 
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
-        train_getLocale(resources, Locale.ENGLISH);
         train_getContainerMessages(resources, containerMessages);
-        
+
         train_alwaysNull(macro);
 
         train_contains(containerMessages, "form-fred-required-message", false);
@@ -179,7 +167,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(null, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidator(field, "required", null);
 
@@ -191,7 +179,6 @@ public class FieldValidatorSourceImplTes
     @Test
     public void component_messages_overrides_validator_messages_per_form() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
@@ -210,9 +197,8 @@ public class FieldValidatorSourceImplTes
 
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
-        train_getLocale(resources, Locale.ENGLISH);
         train_getContainerMessages(resources, containerMessages);
-        
+
         train_alwaysNull(macro);
 
         train_contains(containerMessages, "form-fred-required-message", true);
@@ -225,7 +211,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(null, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidator(field, "required", null);
 
@@ -238,15 +224,14 @@ public class FieldValidatorSourceImplTes
     @Test
     public void constraint_value_from_message_catalog_per() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
-        Messages messages = mockMessages();
         MessageFormatter formatter = mockMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = mockComponentResources();
         Messages containerMessages = mockMessages();
+        Messages globalMessages = mockMessages();
         FormSupport fs = mockFormSupport();
 
         Map<String, Validator> map = singletonMap("minlength", validator);
@@ -268,12 +253,8 @@ public class FieldValidatorSourceImplTes
         train_contains(containerMessages, "myform-fred-minlength-message", false);
         train_contains(containerMessages, "fred-minlength-message", false);
 
-        train_getLocale(resources, Locale.FRENCH);
-
-        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);
-
         train_getMessageKey(validator, "key");
-        train_getMessageFormatter(messages, "key", formatter);
+        train_getMessageFormatter(globalMessages, "key", formatter);
 
         train_isRequired(validator, false);
         train_getValueType(validator, Object.class);
@@ -284,7 +265,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(globalMessages, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidators(field, "minlength");
 
@@ -297,11 +278,10 @@ public class FieldValidatorSourceImplTes
     @Test
     public void constraint_value_from_message_catalog_per_form() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
-        Messages messages = mockMessages();
+        Messages globalMessages = mockMessages();
         MessageFormatter formatter = mockMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = mockComponentResources();
@@ -326,12 +306,8 @@ public class FieldValidatorSourceImplTes
         train_contains(containerMessages, "myform-fred-minlength-message", false);
         train_contains(containerMessages, "fred-minlength-message", false);
 
-        train_getLocale(resources, Locale.FRENCH);
-
-        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);
-
         train_getMessageKey(validator, "key");
-        train_getMessageFormatter(messages, "key", formatter);
+        train_getMessageFormatter(globalMessages, "key", formatter);
 
         train_isRequired(validator, false);
         train_getValueType(validator, Object.class);
@@ -342,7 +318,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(globalMessages, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidators(field, "minlength");
 
@@ -355,7 +331,6 @@ public class FieldValidatorSourceImplTes
     @Test
     public void missing_field_validator_constraint() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
@@ -371,7 +346,6 @@ public class FieldValidatorSourceImplTes
 
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
-        train_getLocale(resources, Locale.GERMAN);
         train_getContainerMessages(resources, containerMessages);
 
         train_contains(containerMessages, "myform-fred-minlength", false);
@@ -382,7 +356,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(null, coercer, fs, map, macro);
 
         try
         {
@@ -403,7 +377,6 @@ public class FieldValidatorSourceImplTes
     @Test
     public void single_validator_via_specification() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
@@ -413,6 +386,7 @@ public class FieldValidatorSourceImplTes
         ComponentResources resources = mockComponentResources();
         Messages containerMessages = mockMessages();
         FormSupport fs = mockFormSupport();
+        Messages globalMessages = mockMessages();
 
         Map<String, Validator> map = singletonMap("required", validator);
 
@@ -427,12 +401,8 @@ public class FieldValidatorSourceImplTes
         train_contains(containerMessages, "myform-fred-required-message", false);
         train_contains(containerMessages, "fred-required-message", false);
 
-        train_getLocale(resources, Locale.FRENCH);
-
-        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);
-
         train_getMessageKey(validator, "key");
-        train_getMessageFormatter(messages, "key", formatter);
+        train_getMessageFormatter(globalMessages, "key", formatter);
 
         train_isRequired(validator, false);
         train_getValueType(validator, Object.class);
@@ -443,7 +413,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(globalMessages, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidators(field, "required");
 
@@ -539,7 +509,6 @@ public class FieldValidatorSourceImplTes
     @Test
     public void multiple_validators_via_specification() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator required = mockValidator();
         Validator minLength = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
@@ -552,6 +521,7 @@ public class FieldValidatorSourceImplTes
         Messages containerMessages = mockMessages();
         Integer fifteen = 15;
         FormSupport fs = mockFormSupport();
+        Messages globalMessages = mockMessages();
 
         Map<String, Validator> map = newMap();
 
@@ -569,18 +539,15 @@ public class FieldValidatorSourceImplTes
         train_contains(containerMessages, "myform-fred-required-message", false);
         train_contains(containerMessages, "fred-required-message", false);
 
-        train_getLocale(resources, Locale.FRENCH);
-
-        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);
 
         train_getMessageKey(required, "required");
-        train_getMessageFormatter(messages, "required", requiredFormatter);
+        train_getMessageFormatter(globalMessages, "required", requiredFormatter);
 
         train_contains(containerMessages, "myform-fred-minLength-message", false);
         train_contains(containerMessages, "fred-minLength-message", false);
 
         train_getMessageKey(minLength, "min-length");
-        train_getMessageFormatter(messages, "min-length", minLengthFormatter);
+        train_getMessageFormatter(globalMessages, "min-length", minLengthFormatter);
 
         train_coerce(coercer, "15", Integer.class, fifteen);
 
@@ -597,7 +564,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(globalMessages, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidators(field, "required,minLength=15");
 
@@ -610,11 +577,9 @@ public class FieldValidatorSourceImplTes
     @Test
     public void validator_with_constraint() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
-        Messages messages = mockMessages();
         MessageFormatter formatter = mockMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = mockComponentResources();
@@ -622,6 +587,7 @@ public class FieldValidatorSourceImplTes
         Integer five = 5;
         FormSupport fs = mockFormSupport();
         ValidatorMacro macro = mockValidatorMacro();
+        Messages globalMessages = mockMessages();
 
         Map<String, Validator> map = singletonMap("minLength", validator);
 
@@ -634,18 +600,14 @@ public class FieldValidatorSourceImplTes
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
         train_getContainerMessages(resources, containerMessages);
-        
+
         train_alwaysNull(macro);
-        
+
         train_contains(containerMessages, "myform-fred-minLength-message", false);
         train_contains(containerMessages, "fred-minLength-message", false);
 
-        train_getLocale(resources, Locale.FRENCH);
-
-        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);
-
         train_getMessageKey(validator, "key");
-        train_getMessageFormatter(messages, "key", formatter);
+        train_getMessageFormatter(globalMessages, "key", formatter);
 
         train_isRequired(validator, false);
         train_getValueType(validator, Object.class);
@@ -653,7 +615,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(globalMessages, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidator(field, "minLength", "5");
 
@@ -661,16 +623,14 @@ public class FieldValidatorSourceImplTes
 
         verify();
     }
-    
+
     @SuppressWarnings("unchecked")
     @Test
     public void validator_with_constraint_and_macro() throws Exception
     {
-        ValidationMessagesSource messagesSource = mockValidationMessagesSource();
         Validator validator = mockValidator();
         TypeCoercer coercer = mockTypeCoercer();
         FieldComponent field = newFieldComponent();
-        Messages messages = mockMessages();
         MessageFormatter formatter = mockMessageFormatter();
         Object inputValue = new Object();
         ComponentResources resources = mockComponentResources();
@@ -678,6 +638,7 @@ public class FieldValidatorSourceImplTes
         Integer five = 5;
         FormSupport fs = mockFormSupport();
         ValidatorMacro macro = mockValidatorMacro();
+        Messages globalMessages = mockMessages();
 
         Map<String, Validator> map = singletonMap("minLength", validator);
 
@@ -690,19 +651,15 @@ public class FieldValidatorSourceImplTes
         train_getComponentResources(field, resources);
         train_getId(resources, "fred");
         train_getContainerMessages(resources, containerMessages);
-        
+
         expect(macro.valueForMacro("foo-bar-baz")).andReturn("minLength=77");
         expect(macro.valueForMacro("minLength")).andReturn(null);
-        
+
         train_contains(containerMessages, "myform-fred-minLength-message", false);
         train_contains(containerMessages, "fred-minLength-message", false);
 
-        train_getLocale(resources, Locale.FRENCH);
-
-        train_getValidationMessages(messagesSource, Locale.FRENCH, messages);
-
         train_getMessageKey(validator, "key");
-        train_getMessageFormatter(messages, "key", formatter);
+        train_getMessageFormatter(globalMessages, "key", formatter);
 
         train_isRequired(validator, false);
         train_getValueType(validator, Object.class);
@@ -710,7 +667,7 @@ public class FieldValidatorSourceImplTes
 
         replay();
 
-        FieldValidatorSource source = new FieldValidatorSourceImpl(messagesSource, coercer, fs, map, macro);
+        FieldValidatorSource source = new FieldValidatorSourceImpl(globalMessages, coercer, fs, map, macro);
 
         FieldValidator fieldValidator = source.createValidator(field, "foo-bar-baz", null);