struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [4/4] git commit: Extends annotation to support new URL regex parameters
Date Sun, 09 Mar 2014 20:04:52 GMT
Extends annotation to support new URL regex parameters


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e66a3062
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e66a3062
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e66a3062

Branch: refs/heads/feature/WW-4198-update-form-close
Commit: e66a3062992fac588cf3f570a224bbe7d9ce5ef5
Parents: 3f6ce65
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Sun Mar 9 21:04:11 2014 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Sun Mar 9 21:04:11 2014 +0100

----------------------------------------------------------------------
 ...nnotationValidationConfigurationBuilder.java |  6 ++
 .../validator/annotations/UrlValidator.java     | 74 +++-----------------
 2 files changed, 16 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/e66a3062/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
index 6ab06a9..dbd8975 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/AnnotationValidationConfigurationBuilder.java
@@ -528,6 +528,12 @@ public class AnnotationValidationConfigurationBuilder {
         } else if (v.fieldName() != null && v.fieldName().length() > 0) {
             params.put("fieldName", v.fieldName());
         }
+        if (StringUtils.isNotEmpty(v.urlRegex())) {
+            params.put("urlRegex", v.urlRegex());
+        }
+        if (StringUtils.isNotEmpty(v.urlRegexExpression())) {
+            params.put("urlRegexExpression", v.urlRegexExpression());
+        }
 
         validatorFactory.lookupRegisteredValidatorType(validatorType);
         return new ValidatorConfig.Builder(validatorType)

http://git-wip-us.apache.org/repos/asf/struts/blob/e66a3062/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/UrlValidator.java
----------------------------------------------------------------------
diff --git a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/UrlValidator.java
b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/UrlValidator.java
index fb6fa3c..a06db12 100644
--- a/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/UrlValidator.java
+++ b/xwork-core/src/main/java/com/opensymphony/xwork2/validator/annotations/UrlValidator.java
@@ -22,75 +22,12 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 /**
- * <!-- START SNIPPET: description -->
  * This validator checks that a field is a valid URL.
- * <!-- END SNIPPET: description -->
- *
- * <p/> <u>Annotation usage:</u>
- *
- * <!-- START SNIPPET: usage -->
- * <p/>The annotation must be applied at method level.
- * <!-- END SNIPPET: usage -->
- *
- * <p/> <u>Annotation parameters:</u>
- *
- * <!-- START SNIPPET: parameters -->
- * <table class='confluenceTable'>
- * <tr>
- * <th class='confluenceTh'> Parameter </th>
- * <th class='confluenceTh'> Required </th>
- * <th class='confluenceTh'> Default </th>
- * <th class='confluenceTh'> Notes </th>
- * </tr>
- * <tr>
- * <td class='confluenceTd'>message</td>
- * <td class='confluenceTd'>yes</td>
- * <td class='confluenceTd'>&nbsp;</td>
- * <td class='confluenceTd'>field error message</td>
- * </tr>
- * <tr>
- * <td class='confluenceTd'>key</td>
- * <td class='confluenceTd'>no</td>
- * <td class='confluenceTd'>&nbsp;</td>
- * <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>
- * <td class='confluenceTd'>&nbsp;</td>
- * </tr>
- * <tr>
- * <td class='confluenceTd'>shortCircuit</td>
- * <td class='confluenceTd'>no</td>
- * <td class='confluenceTd'>false</td>
- * <td class='confluenceTd'>If this validator should be used as shortCircuit.</td>
- * </tr>
- * <tr>
- * <td class='confluenceTd'>type</td>
- * <td class='confluenceTd'>yes</td>
- * <td class='confluenceTd'>ValidatorType.FIELD</td>
- * <td class='confluenceTd'>Enum value from ValidatorType. Either FIELD or SIMPLE can
be used here.</td>
- * </tr>
- * </table>
- * <!-- END SNIPPET: parameters -->
- *
- * <p/> <u>Example code:</u>
  *
  * <pre>
- * <!-- START SNIPPET: example -->
  * &#64;UrlValidator(message = "Default message", key = "i18n.key", shortCircuit = true)
- * <!-- END SNIPPET: example -->
  * </pre>
  *
- * @author Rainer Hermanns
- * @version $Id$
  */
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
@@ -121,7 +58,6 @@ public @interface UrlValidator {
      * If this is activated, the validator will be used as short-circuit.
      *
      * Adds the short-circuit="true" attribute value if <tt>true</tt>.
-     *
      */
     boolean shortCircuit() default false;
 
@@ -130,4 +66,14 @@ public @interface UrlValidator {
      */
     ValidatorType type() default ValidatorType.FIELD;
 
+    /**
+     * Defines regex to use to validate url
+     */
+    String urlRegex() default "";
+
+    /**
+     * Defines regex as an expression which will be evaluated to string and used to validate
url
+     */
+    String urlRegexExpression() default "";
+
 }


Mime
View raw message