[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Wed Feb 14 02:05:42 EST 2007
User: gavin
Date: 07/02/14 02:05:42
Modified: src/main/org/jboss/seam/core Expressions.java
Log:
fixed a problem
Revision Changes Path
1.16 +23 -6 jboss-seam/src/main/org/jboss/seam/core/Expressions.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Expressions.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Expressions.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- Expressions.java 14 Feb 2007 05:46:29 -0000 1.15
+++ Expressions.java 14 Feb 2007 07:05:42 -0000 1.16
@@ -1,4 +1,4 @@
-//$Id: Expressions.java,v 1.15 2007/02/14 05:46:29 gavin Exp $
+//$Id: Expressions.java,v 1.16 2007/02/14 07:05:42 gavin Exp $
package org.jboss.seam.core;
import static org.jboss.seam.InterceptionType.NEVER;
@@ -8,6 +8,7 @@
import javax.faces.context.FacesContext;
+import org.hibernate.validator.ClassValidator;
import org.hibernate.validator.InvalidValue;
import org.jboss.seam.Component;
import org.jboss.seam.Model;
@@ -162,22 +163,38 @@
{
return new InvalidValue[0];
}
- //String componentName;
+ String componentName;
String propertyName;
if (dot>bracket)
{
- //componentName = propertyExpression.substring(2, dot);
+ componentName = propertyExpression.substring(2, dot);
propertyName = propertyExpression.substring( dot+1, propertyExpression.length()-1 );
}
else
{
- //componentName = propertyExpression.substring(2, bracket);
+ componentName = propertyExpression.substring(2, bracket);
propertyName = propertyExpression.substring( bracket+1, propertyExpression.length()-2 );
}
String modelExpression = propertyExpression.substring(0, dot) + '}';
- Object model = createValueBinding(modelExpression).getValue(); //TODO: cache the ValueBinding object!
- return Model.forClass( model.getClass() ).getValidator().getPotentialInvalidValues(propertyName, value);
+ Object modelInstance = createValueBinding(modelExpression).getValue(); //TODO: cache the ValueBinding object!
+ return getValidator(modelInstance, componentName).getPotentialInvalidValues(propertyName, value);
+ }
+
+ /**
+ * Gets the validator from the Component object (if this is a Seam
+ * component, we need to use the validator for the bean class, not
+ * the proxy class) or from a Model object (if it is not a Seam
+ * component, there isn't any proxy).
+ *
+ * @param instance the object to be validated
+ * @param componentName the name of the context variable, which might be a component name
+ * @return a ClassValidator object
+ */
+ private static ClassValidator getValidator(Object instance, String componentName)
+ {
+ Component component = Component.forName(componentName);
+ return ( component==null ? Model.forClass( instance.getClass() ) : component ).getValidator();
}
public static interface ValueBinding<T> extends Serializable
More information about the jboss-cvs-commits
mailing list