struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject svn commit: r1457746 - in /struts/struts2/trunk/xwork-core/src: main/java/com/opensymphony/xwork2/validator/ main/java/com/opensymphony/xwork2/validator/annotations/ test/java/com/opensymphony/xwork2/validator/
Date Mon, 18 Mar 2013 13:01:47 GMT
Author: lukaszlenart
Date: Mon Mar 18 13:01:47 2013
New Revision: 1457746

URL: http://svn.apache.org/r1457746
Log:
WW-4014 Improves VisitorFieldValidator annotation to match VisitorFieldValidator class

Modified:
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
    struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/VisitorFieldValidator.java
    struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java
    struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
    struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationExpAction.java

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java?rev=1457746&r1=1457745&r2=1457746&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
Mon Mar 18 13:01:47 2013
@@ -514,6 +514,7 @@ public class AnnotationValidationConfigu
                 .shortCircuit(v.shortCircuit())
                 .defaultMessage(v.message())
                 .messageKey(v.key())
+                .messageParams(v.messageParams())
                 .build();
     }
 

Modified: struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/VisitorFieldValidator.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/VisitorFieldValidator.java?rev=1457746&r1=1457745&r2=1457746&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/VisitorFieldValidator.java
(original)
+++ struts/struts2/trunk/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/VisitorFieldValidator.java
Mon Mar 18 13:01:47 2013
@@ -62,6 +62,12 @@ import java.lang.annotation.Target;
  * <td class='confluenceTd'>i18n key from language specific properties file.</td>
  * </tr>
  * <tr>
+ * <td class='confluenceTd'>messageParams</td>
+ * <td class='confluenceTd'>no</td>
+ * <td class='confluenceTd'>&nbsp;</td>
+ * <td class='confluenceTd'>Additional params to be used to customize message - will
be evaluated against the Value Stack</td>
+ * </tr>
+ * <tr>
  * <td class='confluenceTd'>fieldName</td>
  * <td class='confluenceTd'>no</td>
  * <td class='confluenceTd'>&nbsp;</td>
@@ -141,6 +147,11 @@ public @interface VisitorFieldValidator 
     String fieldName() default "";
 
     /**
+     * Additional params to be used to customize message - will be evaluated against the
Value Stack
+     */
+    String[] messageParams() default {};
+
+    /**
      * If this is activated, the validator will be used as short-circuit.
      *
      * Adds the short-circuit="true" attribute value if <tt>true</tt>.

Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java?rev=1457746&r1=1457745&r2=1457746&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java
(original)
+++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationAction.java
Mon Mar 18 13:01:47 2013
@@ -17,6 +17,7 @@ import com.opensymphony.xwork2.validator
 import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
 import com.opensymphony.xwork2.validator.annotations.UrlValidator;
 import com.opensymphony.xwork2.validator.annotations.ValidationParameter;
+import com.opensymphony.xwork2.validator.annotations.VisitorFieldValidator;
 
 /**
  * Sets up all available validation annotations
@@ -60,6 +61,8 @@ public class AnnotationValidationAction 
             maxLength = "10", minLength = "1", shortCircuit = true, trim = false, messageParams
= {"one", "two", "three"})
     @UrlValidator(fieldName = "foo", key = "url.key", message = "Foo isn't a valid URL!",
shortCircuit = true,
             messageParams = {"one", "two", "three"})
+    @VisitorFieldValidator(message = "Foo isn't valid!", key = "visitorfield.key", fieldName
= "foo", appendPrefix = false,
+            shortCircuit = true, messageParams = {"one", "two", "three"})
     public String execute() {
         return SUCCESS;
     }

Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java?rev=1457746&r1=1457745&r2=1457746&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
(original)
+++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilderTest.java
Mon Mar 18 13:01:47 2013
@@ -28,6 +28,7 @@ import com.opensymphony.xwork2.validator
 import com.opensymphony.xwork2.validator.validators.ShortRangeFieldValidator;
 import com.opensymphony.xwork2.validator.validators.StringLengthFieldValidator;
 import com.opensymphony.xwork2.validator.validators.URLValidator;
+import com.opensymphony.xwork2.validator.validators.VisitorFieldValidator;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -49,7 +50,7 @@ public class AnnotationValidationConfigu
         List<Validator> validators = manager.getValidators(AnnotationValidationAction.class,
null);
 
         // then
-        assertEquals(validators.size(), 15);
+        assertEquals(validators.size(), 16);
         for (Validator validator : validators) {
             validate(validator);
         }
@@ -66,7 +67,7 @@ public class AnnotationValidationConfigu
         ValueStack valueStack = container.getInstance(ValueStackFactory.class).createValueStack();
         valueStack.push(new AnnotationValidationExpAction());
 
-        assertEquals(validators.size(), 15);
+        assertEquals(validators.size(), 16);
         for (Validator validator : validators) {
             validator.setValueStack(valueStack);
             validate(validator);
@@ -104,9 +105,20 @@ public class AnnotationValidationConfigu
             validateStringLengthFieldValidator((StringLengthFieldValidator) validator);
         } else if (validator.getValidatorType().equals("url")) {
             validateUrlValidator((URLValidator) validator);
+        } else if (validator.getValidatorType().equals("visitor")) {
+            validateVisitorFieldValidator((VisitorFieldValidator) validator);
         }
     }
 
+    private void validateVisitorFieldValidator(VisitorFieldValidator validator) {
+        assertEquals("foo", validator.getFieldName());
+        assertEquals("visitorfield.key", validator.getMessageKey());
+        assertEquals("Foo isn't valid!", validator.getDefaultMessage());
+        assertTrue(Arrays.equals(new String[]{"one", "two", "three"}, validator.getMessageParameters()));
+        assertEquals(false, validator.isAppendPrefix());
+        assertEquals(true, validator.isShortCircuit());
+    }
+
     private void validateUrlValidator(URLValidator validator) {
         assertEquals("foo", validator.getFieldName());
         assertEquals("Foo isn't a valid URL!", validator.getDefaultMessage());

Modified: struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationExpAction.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationExpAction.java?rev=1457746&r1=1457745&r2=1457746&view=diff
==============================================================================
--- struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationExpAction.java
(original)
+++ struts/struts2/trunk/xwork-core/src/test/java/com/opensymphony/xwork2/validator/AnnotationValidationExpAction.java
Mon Mar 18 13:01:47 2013
@@ -17,6 +17,7 @@ import com.opensymphony.xwork2.validator
 import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
 import com.opensymphony.xwork2.validator.annotations.UrlValidator;
 import com.opensymphony.xwork2.validator.annotations.ValidationParameter;
+import com.opensymphony.xwork2.validator.annotations.VisitorFieldValidator;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -68,6 +69,8 @@ public class AnnotationValidationExpActi
             messageParams = {"one", "two", "three"})
     @UrlValidator(fieldName = "foo", key = "url.key", message = "Foo isn't a valid URL!",
shortCircuit = true,
             messageParams = {"one", "two", "three"})
+    @VisitorFieldValidator(message = "Foo isn't valid!", key = "visitorfield.key", fieldName
= "foo", appendPrefix = false,
+            shortCircuit = true, messageParams = {"one", "two", "three"})
     public String execute() {
         return SUCCESS;
     }



Mime
View raw message