You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/01/18 09:16:36 UTC
svn commit: r613096 - in
/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago:
application/ViewHandlerImpl.java component/UIViewRoot.java
context/ClientProperties.java context/ResourceManagerImpl.java
Author: bommel
Date: Fri Jan 18 00:16:35 2008
New Revision: 613096
URL: http://svn.apache.org/viewvc?rev=613096&view=rev
Log:
(TOBAGO-600) Simplify ResourceManagerImpl.CacheKey and ClientProperties handling in UIViewRoot and ViewHandlerImpl
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java?rev=613096&r1=613095&r2=613096&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/application/ViewHandlerImpl.java Fri Jan 18 00:16:35 2008
@@ -19,9 +19,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.apache.myfaces.tobago.TobagoConstants.ATTR_CLIENT_PROPERTIES;
import org.apache.myfaces.tobago.component.ComponentUtil;
-import org.apache.myfaces.tobago.context.ClientProperties;
import org.apache.myfaces.tobago.util.RequestUtils;
import javax.faces.FacesException;
@@ -35,8 +33,6 @@
private static final Log LOG = LogFactory.getLog(ViewHandlerImpl.class);
- public static final String PAGE_ID = "tobago::page-id";
-
private ViewHandler base;
public ViewHandlerImpl(ViewHandler base) {
@@ -70,20 +66,9 @@
tobagoViewRoot.setRenderKitId(viewRoot.getRenderKitId());
viewRoot = tobagoViewRoot;
}
- ensureClientProperties(facesContext, viewRoot);
-
return viewRoot;
}
- private void ensureClientProperties(FacesContext facesContext,
- UIViewRoot viewRoot) {
- if (viewRoot != null) {
- ClientProperties clientProperties
- = ClientProperties.getInstance(facesContext);
- viewRoot.getAttributes().put(ATTR_CLIENT_PROPERTIES, clientProperties);
- }
- }
-
public String getActionURL(FacesContext facesContext, String viewId) {
return base.getActionURL(facesContext, viewId);
}
@@ -111,7 +96,6 @@
// TODO: maybe find a way to make this unneeded
RequestUtils.ensureEncoding(facesContext.getExternalContext());
UIViewRoot viewRoot = base.restoreView(facesContext, viewId);
- ensureClientProperties(facesContext, viewRoot);
return viewRoot;
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java?rev=613096&r1=613095&r2=613096&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/component/UIViewRoot.java Fri Jan 18 00:16:35 2008
@@ -45,9 +45,8 @@
private ResourceManagerImpl.CacheKey rendererCacheKey;
- private ClientProperties clientProperties;
-
public static final int ANY_PHASE_ORDINAL = PhaseId.ANY_PHASE.getOrdinal();
+
private List events = null;
@@ -60,15 +59,6 @@
updateRendererCachePrefix();
}
- public ClientProperties getClientProperties() {
- return clientProperties;
- }
-
- public void setClientProperties(ClientProperties clientProperties) {
- this.clientProperties = clientProperties;
- updateRendererCachePrefix();
- }
-
public void setLocale(Locale locale) {
super.setLocale(locale);
updateRendererCachePrefix();
@@ -80,9 +70,9 @@
public void updateRendererCachePrefix() {
+ ClientProperties clientProperties = ClientProperties.getInstance(this);
rendererCacheKey = ResourceManagerImpl.getRendererCacheKey(
clientProperties != null ? clientProperties.getId() : "null", getLocale());
-// LOG.info("updateRendererCachePrefix :" + rendererCachePrefix);
}
public void broadcastEventsForPhase(FacesContext context, PhaseId phaseId) {
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java?rev=613096&r1=613095&r2=613096&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ClientProperties.java Fri Jan 18 00:16:35 2008
@@ -116,14 +116,19 @@
}
public static ClientProperties getInstance(UIViewRoot viewRoot) {
-
- ClientProperties instance = (ClientProperties)
- viewRoot.getAttributes().get(ATTR_CLIENT_PROPERTIES);
- if (instance == null) {
- LOG.error("No ClientProperties instance found creating new one");
+ if (viewRoot == null) {
+ LOG.error("No ViewRoot found creating new ClientProperties.");
return getInstance(FacesContext.getCurrentInstance());
}
- return instance;
+ ClientProperties clientProperties = (ClientProperties)
+ viewRoot.getAttributes().get(ATTR_CLIENT_PROPERTIES);
+ if (clientProperties == null) {
+ LOG.info("No ClientProperties instance found creating new one");
+ clientProperties = getInstance(FacesContext.getCurrentInstance());
+ viewRoot.getAttributes().put(ATTR_CLIENT_PROPERTIES, clientProperties);
+ return clientProperties;
+ }
+ return clientProperties;
}
public static ClientProperties getInstance(FacesContext facesContext) {
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java?rev=613096&r1=613095&r2=613096&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerImpl.java Fri Jan 18 00:16:35 2008
@@ -23,6 +23,7 @@
import org.apache.myfaces.tobago.config.TobagoConfig;
import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
import javax.faces.render.Renderer;
import java.util.ArrayList;
import java.util.HashMap;
@@ -118,7 +119,15 @@
key = ((org.apache.myfaces.tobago.component.UIViewRoot) viewRoot).getRendererCacheKey();
} else {
String clientPropertyId = ClientProperties.getInstance(viewRoot).getId();
- Locale locale = viewRoot.getLocale();
+ Locale locale;
+ if (viewRoot != null) {
+ locale = viewRoot.getLocale();
+ } else {
+ LOG.error("No ViewRoot available calculate Locale for CacheKey.");
+ locale =
+ FacesContext.getCurrentInstance().getApplication().getViewHandler()
+ .calculateLocale(FacesContext.getCurrentInstance());
+ }
key = new CacheKey(clientPropertyId, locale);
}
return key;
@@ -174,7 +183,6 @@
boolean reverseOrder, boolean single, boolean returnKey,
String key, boolean returnStrings, boolean ignoreMissing) {
List matches = new ArrayList();
-
StringTokenizer tokenizer = new StringTokenizer(clientProperties, "/");
String contentType = tokenizer.nextToken();
Theme theme = tobagoConfig.getTheme(tokenizer.nextToken());