You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/11/23 19:47:30 UTC
svn commit: r1038270 -
/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java
Author: lu4242
Date: Tue Nov 23 18:47:30 2010
New Revision: 1038270
URL: http://svn.apache.org/viewvc?rev=1038270&view=rev
Log:
MFCOMMONS-26 validateRegExpr doesnt support value binding in patter property
Modified:
myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java
Modified: myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java
URL: http://svn.apache.org/viewvc/myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java?rev=1038270&r1=1038269&r2=1038270&view=diff
==============================================================================
--- myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java (original)
+++ myfaces/commons/trunk/myfaces-commons-validators/src/main/java/org/apache/myfaces/commons/validator/AbstractRegExprValidator.java Tue Nov 23 18:47:30 2010
@@ -70,7 +70,16 @@ public abstract class AbstractRegExprVal
return;
}
Object[] args = {value.toString()};
- if(!GenericValidator.matchRegexp(value.toString(),"^"+getPattern()+"$")){
+ String pattern = getPattern();
+ if (pattern == null)
+ {
+ pattern = getPatternExpression();
+ }
+ else if (pattern != null && pattern.length() <= 0)
+ {
+ pattern = getPatternExpression();
+ }
+ if(!GenericValidator.matchRegexp(value.toString(),"^"+pattern+"$")){
throw new ValidatorException(getFacesMessage(REGEXPR_MESSAGE_ID, args));
}
}
@@ -78,7 +87,8 @@ public abstract class AbstractRegExprVal
// -------------------------------------------------------- GETTER & SETTER
/**
- * the pattern, which is the base of the validation
+ * the pattern, which is the base of the validation. It does
+ * not allow EL expressions (jsp special case).
*
* @return the pattern, on which a value should be validated
*/
@@ -91,4 +101,14 @@ public abstract class AbstractRegExprVal
*/
public abstract void setPattern(String string);
+ /**
+ * the pattern, which is the base of the validation. It
+ * allow EL expressions.
+ *
+ * @return the pattern, on which a value should be validated
+ */
+ @JSFProperty
+ public abstract String getPatternExpression();
+
+
}