diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java index c954411f..62ea8174 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/ExternalContext.java @@ -17,6 +17,7 @@ package org.springframework.webflow.context; import java.io.Writer; import java.security.Principal; +import java.util.Locale; import org.springframework.webflow.core.collection.AttributeMap; import org.springframework.webflow.core.collection.MutableAttributeMap; @@ -107,6 +108,12 @@ public interface ExternalContext { */ public Principal getCurrentUser(); + /** + * Returns the client locale. + * @return the locale + */ + public Locale getLocale(); + /** * Provides access to the context object for the current environment. * @return the environment specific context object diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java index 91281273..39035fba 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/portlet/PortletExternalContext.java @@ -3,6 +3,7 @@ package org.springframework.webflow.context.portlet; import java.io.IOException; import java.io.Writer; import java.security.Principal; +import java.util.Locale; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; @@ -159,6 +160,10 @@ public class PortletExternalContext implements ExternalContext { return request.getUserPrincipal(); } + public Locale getLocale() { + return request.getLocale(); + } + public Object getNativeContext() { return context; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java index 57028368..b575bd8a 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/servlet/ServletExternalContext.java @@ -18,6 +18,7 @@ package org.springframework.webflow.context.servlet; import java.io.IOException; import java.io.Writer; import java.security.Principal; +import java.util.Locale; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -175,6 +176,10 @@ public class ServletExternalContext implements ExternalContext { return request.getUserPrincipal(); } + public Locale getLocale() { + return request.getLocale(); + } + public Object getNativeContext() { return context; } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java b/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java index d468edf2..4853def0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/test/MockExternalContext.java @@ -19,6 +19,7 @@ import java.io.StringWriter; import java.io.Writer; import java.security.Principal; import java.util.HashMap; +import java.util.Locale; import org.springframework.binding.collection.SharedMapDecorator; import org.springframework.webflow.context.ExternalContext; @@ -56,6 +57,8 @@ public class MockExternalContext implements ExternalContext { private Principal currentUser; + private Locale locale; + private StringWriter responseWriter = new StringWriter(); private boolean ajaxRequest; @@ -117,6 +120,10 @@ public class MockExternalContext implements ExternalContext { return currentUser; } + public Locale getLocale() { + return locale; + } + public Object getNativeContext() { return nativeContext; } @@ -247,6 +254,14 @@ public class MockExternalContext implements ExternalContext { this.currentUser = new MockPrincipal(currentUser); } + /** + * Sets the client locale. + * @param locale the locale + */ + public void setLocale(Locale locale) { + this.locale = locale; + } + // convenience helpers /**