Author: nbelaevski
Date: 2008-08-05 18:39:55 -0400 (Tue, 05 Aug 2008)
New Revision: 9928
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java
Log:
https://jira.jboss.org/jira/browse/RF-4034
Modified: trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2008-08-05
18:00:31 UTC (rev 9927)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/BeanValidator.java 2008-08-05
22:39:55 UTC (rev 9928)
@@ -111,11 +111,9 @@
if (null != target) {
ELContext elContext = context.getELContext();
ValidationResolver validationResolver = new ValidationResolver(
- elContext.getELResolver());
+ elContext.getELResolver(), calculateLocale(context));
ELContextWrapper wrappedElContext = new ELContextWrapper(elContext,
validationResolver);
- Locale locale = calculateLocale(context);
- wrappedElContext.setLocale(locale);
// TODO - handle ELExceptions ?
try {
target.setValue(wrappedElContext, value);
@@ -304,11 +302,14 @@
private String[] validationMessages = null;
+ private Locale locale = null;
+
/**
* @param parent
*/
- public ValidationResolver(ELResolver parent) {
+ public ValidationResolver(ELResolver parent, Locale locale) {
this.parent = parent;
+ this.locale = locale;
}
public boolean isValid() {
@@ -388,8 +389,10 @@
Object value) {
if (null != base && null != property) {
context.setPropertyResolved(true);
- validationMessages = validate(base, property.toString(), value,
- context.getLocale());
+ //https://jira.jboss.org/jira/browse/RF-4034
+ //apache el looses locale information during value resolution,
+ //so we use our own
+ validationMessages = validate(base, property.toString(), value, locale);
valid = null == validationMessages
|| 0 == validationMessages.length;
}
Modified:
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java
===================================================================
---
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java 2008-08-05
18:00:31 UTC (rev 9927)
+++
trunk/ui/beanValidator/src/main/java/org/richfaces/validator/ELContextWrapper.java 2008-08-05
22:39:55 UTC (rev 9928)
@@ -3,6 +3,8 @@
*/
package org.richfaces.validator;
+import java.util.Locale;
+
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.FunctionMapper;
@@ -69,4 +71,11 @@
parent.putContext(key, contextObject);
}
+ public Locale getLocale() {
+ return parent.getLocale();
+ }
+
+ public void setLocale(Locale locale) {
+ parent.setLocale(locale);
+ }
}