You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/10/29 10:21:26 UTC
svn commit: r1536618 - in
/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago:
context/ClientProperties.java internal/context/ClientPropertiesKey.java
Author: lofwyr
Date: Tue Oct 29 09:21:26 2013
New Revision: 1536618
URL: http://svn.apache.org/r1536618
Log:
TOBAGO-1335: Remove locale from ClientProperties
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ClientPropertiesKey.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java?rev=1536618&r1=1536617&r2=1536618&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java Tue Oct 29 09:21:26 2013
@@ -19,9 +19,9 @@
package org.apache.myfaces.tobago.context;
-import org.apache.commons.lang.ObjectUtils;
import org.apache.myfaces.tobago.config.TobagoConfig;
import org.apache.myfaces.tobago.internal.context.ClientPropertiesKey;
+import org.apache.myfaces.tobago.internal.util.Deprecation;
import org.apache.myfaces.tobago.layout.Measure;
import org.apache.myfaces.tobago.util.VariableResolverUtils;
import org.slf4j.Logger;
@@ -31,8 +31,6 @@ import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Locale;
/**
@@ -61,8 +59,6 @@ public class ClientProperties implements
private UserAgent userAgent = UserAgent.DEFAULT;
private boolean debugMode;
- private Locale locale;
-
private Measure verticalScrollbarWeight;
private Measure horizontalScrollbarWeight;
@@ -73,14 +69,6 @@ public class ClientProperties implements
this(FacesContext.getCurrentInstance());
}
- /**
- * @deprecated since 1.5.
- */
- private ClientProperties(TobagoConfig tobagoConfig) {
- theme = tobagoConfig.getDefaultTheme();
- reset();
- }
-
private ClientProperties(FacesContext facesContext) {
ExternalContext externalContext = facesContext.getExternalContext();
@@ -115,48 +103,10 @@ public class ClientProperties implements
reset();
}
- /**
- * @deprecated since 1.5.
- */
- @Deprecated
- public static ClientProperties getDefaultInstance(FacesContext facesContext) {
- return new ClientProperties(TobagoConfig.getInstance(facesContext));
- }
-
- /**
- * @deprecated since 1.5. Please use
- * {@link #getInstance(javax.faces.context.FacesContext)}
- */
- @Deprecated
- public static ClientProperties getInstance(UIViewRoot viewRoot) {
- return getInstance(FacesContext.getCurrentInstance());
- }
-
public static ClientProperties getInstance(FacesContext facesContext) {
return (ClientProperties) VariableResolverUtils.resolveVariable(facesContext, MANAGED_BEAN_NAME);
}
- /**
- * @deprecated since 1.5. Please use
- * {@link org.apache.myfaces.tobago.util.LocaleUtils#getLocaleSuffixList(java.util.Locale)}
- */
- @Deprecated
- public static List<String> getLocaleList(Locale locale, boolean propertyPathMode) {
- String string = locale.toString();
- String prefix = propertyPathMode ? "" : "_";
- List<String> locales = new ArrayList<String>(4);
- locales.add(prefix + string);
- int underscore;
- while ((underscore = string.lastIndexOf('_')) > 0) {
- string = string.substring(0, underscore);
- locales.add(prefix + string);
- }
-
- locales.add(propertyPathMode ? "default" : ""); // default suffix
-
- return locales;
- }
-
private void reset() {
ClientPropertiesKey.reset(FacesContext.getCurrentInstance());
}
@@ -196,21 +146,22 @@ public class ClientProperties implements
this.debugMode = debugMode;
}
+ /**
+ * @deprecated since 2.0.0, please use {@link UIViewRoot#getLocale()}
+ */
public Locale getLocale() {
- return locale;
+ Deprecation.LOG.warn("Please get locale via UIViewRoot.");
+ return FacesContext.getCurrentInstance().getViewRoot().getLocale();
}
/**
- * Holds the locale of the user, which is located in the UIViewRoot.
- * This setter should not be called from the application directly,
+ * @deprecated since 2.0.0
+ * This setter should not be called from the application directly,
* but via {@link UIViewRoot#setLocale(Locale locale)}
*/
public void setLocale(Locale locale) {
- // set locale will be called "too often" from the JSF
- if (!ObjectUtils.equals(this.locale, locale)) {
- this.locale = locale;
- reset();
- }
+ Deprecation.LOG.warn("Please set locale via UIViewRoot.");
+ FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
}
public Measure getVerticalScrollbarWeight() {
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ClientPropertiesKey.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ClientPropertiesKey.java?rev=1536618&r1=1536617&r2=1536618&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ClientPropertiesKey.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/context/ClientPropertiesKey.java Tue Oct 29 09:21:26 2013
@@ -24,6 +24,7 @@ import org.apache.myfaces.tobago.context
import org.apache.myfaces.tobago.context.UserAgent;
import org.apache.myfaces.tobago.util.VariableResolverUtils;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import java.io.Serializable;
import java.util.Locale;
@@ -46,7 +47,7 @@ public final class ClientPropertiesKey i
ClientPropertiesKey key = (ClientPropertiesKey) requestMap.get(KEY_IN_REQUEST);
if (key == null) {
ClientProperties clientProperties = VariableResolverUtils.resolveClientProperties(facesContext);
- key = new ClientPropertiesKey(clientProperties);
+ key = new ClientPropertiesKey(clientProperties, facesContext.getViewRoot());
requestMap.put(KEY_IN_REQUEST, key);
}
@@ -58,11 +59,11 @@ public final class ClientPropertiesKey i
requestMap.remove(KEY_IN_REQUEST);
}
- private ClientPropertiesKey(ClientProperties clientProperties) {
+ private ClientPropertiesKey(final ClientProperties clientProperties, final UIViewRoot viewRoot) {
contentType = clientProperties.getContentType();
theme = clientProperties.getTheme();
userAgent = clientProperties.getUserAgent();
- locale = clientProperties.getLocale();
+ locale = viewRoot.getLocale();
hashCode = calcHashCode();
}