Author: nbelaevski
Date: 2010-05-21 08:58:49 -0400 (Fri, 21 May 2010)
New Revision: 17172
Added:
root/core/trunk/impl/src/main/java/org/richfaces/context/SkinningResourcesPhaseListener.java
root/core/trunk/impl/src/main/java/org/richfaces/el/
root/core/trunk/impl/src/main/java/org/richfaces/el/BaseReadOnlyValueExpression.java
root/core/trunk/impl/src/main/resources/META-INF/skinning-resources-listener.faces-config.xml
Removed:
root/core/trunk/impl/src/main/java/org/richfaces/context/ContextProvider.java
root/core/trunk/impl/src/main/java/org/richfaces/context/SingletonsContext.java
Modified:
root/core/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
root/core/trunk/impl/src/main/java/org/richfaces/context/PreRenderViewListener.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
root/core/trunk/impl/src/main/resources/META-INF/resources/basic.ecss
root/core/trunk/impl/src/main/resources/META-INF/resources/basic_classes.ecss
Log:
https://jira.jboss.org/browse/RF-8664
Modified: root/core/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java
===================================================================
---
root/core/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java 2010-05-20
23:27:53 UTC (rev 17171)
+++
root/core/trunk/api/src/main/java/org/richfaces/application/ServiceTracker.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -23,8 +23,11 @@
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
import javax.faces.context.FacesContext;
@@ -55,6 +58,10 @@
private volatile Map<Class<?>, Object> servicesMap = new
HashMap<Class<?>, Object>();
+ private final Date startTime = new Date();
+
+ private final ConcurrentMap<Object, Object> concurrentStorage = new
ConcurrentHashMap<Object, Object>();
+
private ServiceTracker() {
//utility class private constructor
}
@@ -215,6 +222,27 @@
serviceTracker.lockModification();
}
+ /**
+ * Returns {@link ServiceTracker} instantiation time. Corresponds to application
initialization time.
+ *
+ * @param context
+ * @return instantiation time
+ */
+ public static Date getStartTime(FacesContext context) {
+ return getServiceTracker(context).startTime;
+ }
+
+ /**
+ * Returns {@link ConcurrentMap} stored in {@link ServiceTracker}. This map is
intended
+ * to be used as fast application-scoped storage.
+ *
+ * @param context
+ * @return
+ */
+ public static ConcurrentMap<Object, Object> getConcurrentStorage(FacesContext
context) {
+ return getServiceTracker(context).concurrentStorage;
+ }
+
private static ServiceTracker getServiceTrackerFromApplicationMap(FacesContext
facesContext) {
Object appContext = facesContext.getExternalContext().getContext();
Modified:
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-05-20
23:27:53 UTC (rev 17171)
+++
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/ContextInitParameters.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -21,10 +21,18 @@
package org.ajax4jsf.context;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
import javax.faces.FacesException;
+import javax.faces.application.Application;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.util.ELUtils;
+import org.richfaces.application.ServiceTracker;
+
/**
* This class hold all methods for get application init parameters. Created for
* single access point to all parameters - simplest for a documentation.
@@ -39,10 +47,21 @@
* If is it equals "true" , framework should proparate exception to
client-side.
*/
public static final String HANDLE_VIEW_EXPIRED_ON_CLIENT =
"org.ajax4jsf.handleViewExpiredOnClient";
- public static final String[] STD_CONTROLS_SKINNING_PARAM =
{"org.richfaces.CONTROL_SKINNING"};
- public static final String[] STD_CONTROLS_SKINNING_CLASSES_PARAM =
{"org.richfaces.CONTROL_SKINNING_CLASSES"};
- public static final String[] CONTROL_SKINNING_LEVEL =
{"org.richfaces.CONTROL_SKINNING_LEVEL"};
+ public static final String STD_CONTROLS_SKINNING_PARAM =
"org.richfaces.CONTROL_SKINNING";
+ public static final String STD_CONTROLS_SKINNING_CLASSES_PARAM =
"org.richfaces.CONTROL_SKINNING_CLASSES";
public static final String[] GLOBAL_QUEUE_ENABLED =
{"org.richfaces.queue.enabled"};
+
+ private static final String ENABLE = "enable";
+
+ private static final String INIT_PARAM_PREFIX =
ContextInitParameters.class.getSimpleName() + ":";
+ private static final Object NULL = new Object() {
+
+ public String toString() {
+ return ContextInitParameters.class.getSimpleName() + ": null
Object";
+ };
+
+ };
+
/**
*
*/
@@ -74,23 +93,14 @@
}
/**
- * Defines what the skinning level used
- *
- * @param context
- * @return value of CONTROL_SKINNING_LEVEL parameter if present
- */
- public static String getSkinningLevel(FacesContext context) {
- return getInitParameter(context, CONTROL_SKINNING_LEVEL);
- }
-
- /**
* Method for determining STD_CONTROLS_SKINNING_PARAM parameter
*
* @param context
* @return value of STD_CONTROLS_SKINNING_PARAM parameter if present.
*/
- public static String getStandartControlSkinningParameter(FacesContext context) {
- return getInitParameter(context, STD_CONTROLS_SKINNING_PARAM);
+ public static boolean isStandardControlSkinningEnabled(FacesContext context) {
+ String paramValue = evaluateInitParameter(context, STD_CONTROLS_SKINNING_PARAM);
+ return paramValue == null /* by default it's on */ ||
ENABLE.equals(paramValue);
}
/**
@@ -99,8 +109,8 @@
* @param context
* @return value of STD_CONTROLS_SKINNING_CLASSES_PARAM parameter if present.
*/
- public static String getStandartControlSkinningClassesParameter(FacesContext context)
{
- return getInitParameter(context, STD_CONTROLS_SKINNING_CLASSES_PARAM);
+ public static boolean isStandardControlSkinningClassesEnabled(FacesContext context)
{
+ return ENABLE.equals(evaluateInitParameter(context,
STD_CONTROLS_SKINNING_CLASSES_PARAM));
}
static int getInteger(FacesContext context, String[] paramNames, int defaulValue) {
@@ -152,4 +162,52 @@
return value;
}
-}
+
+ private static ConcurrentMap<Object, Object> getExpressionsMap(FacesContext
context) {
+ ConcurrentMap<Object, Object> concurrentStorage =
ServiceTracker.getConcurrentStorage(context);
+ return concurrentStorage;
+ }
+
+ private static String evaluateInitParameter(FacesContext context, String
parameterName) {
+ ConcurrentMap<Object, Object> expressionsMap = getExpressionsMap(context);
+ String parameterKey = INIT_PARAM_PREFIX + parameterName;
+
+ Object parameterValue = expressionsMap.get(parameterKey);
+ if (parameterValue == null) {
+ String initParameter =
context.getExternalContext().getInitParameter(parameterName);
+ if (initParameter != null) {
+
+ if (ELUtils.isValueReference(initParameter)) {
+ Application application = context.getApplication();
+ ExpressionFactory expressionFactory =
application.getExpressionFactory();
+
+ parameterValue =
expressionFactory.createValueExpression(context.getELContext(),
+ initParameter,
+ String.class);
+ } else {
+ parameterValue = initParameter;
+ }
+
+ } else {
+ parameterValue = NULL;
+ }
+
+ expressionsMap.put(parameterKey, parameterValue);
+ }
+
+ return evaluateInitParameterExpression(context, parameterValue);
+ }
+
+ private static String evaluateInitParameterExpression(FacesContext context, Object
parameterValue) {
+ if (parameterValue == NULL || parameterValue == null) {
+ return null;
+ } else if (parameterValue instanceof ValueExpression) {
+ ValueExpression expression = (ValueExpression) parameterValue;
+
+ return (String) expression.getValue(context.getELContext());
+ } else {
+ return parameterValue.toString();
+ }
+ }
+
+}
\ No newline at end of file
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/context/ContextProvider.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/context/ContextProvider.java 2010-05-20
23:27:53 UTC (rev 17171)
+++
root/core/trunk/impl/src/main/java/org/richfaces/context/ContextProvider.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -1,62 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.context;
-
-import javax.faces.context.FacesContext;
-import java.util.Map;
-
-/**
- * @author akolonitsky
- * @since Oct 13, 2009
- */
-public abstract class ContextProvider {
- protected final String singletonContextAttributeName;
-
- protected ContextProvider(String attributeSuffixName) {
- this.singletonContextAttributeName = SingletonsContext.class.getName() +
':' + attributeSuffixName;
- }
-
- protected static AttributesContext createContext() {
- return new AttributesContext();
- }
-
- protected abstract Map<? super String, Object> getContextMap(FacesContext
facesContext);
-
- protected AttributesContext createAndStoreContext(FacesContext context) {
- AttributesContext instance = createContext();
-
- getContextMap(context).put(singletonContextAttributeName, instance);
-
- return instance;
- }
-
- public AttributesContext get(FacesContext context) {
- Map<? super String, Object> contextMap = getContextMap(context);
- AttributesContext instance = (AttributesContext)
contextMap.get(singletonContextAttributeName);
-
- if (instance == null) {
- instance = createAndStoreContext(context);
- }
-
- return instance;
- }
-}
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/context/PreRenderViewListener.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/context/PreRenderViewListener.java 2010-05-20
23:27:53 UTC (rev 17171)
+++
root/core/trunk/impl/src/main/java/org/richfaces/context/PreRenderViewListener.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -25,10 +25,6 @@
import java.util.List;
import java.util.Map;
-import org.ajax4jsf.component.QueueRegistry;
-import org.ajax4jsf.context.ContextInitParameters;
-import org.ajax4jsf.javascript.ScriptUtils;
-
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
@@ -37,7 +33,8 @@
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
-import org.richfaces.resource.CompiledCSSResource;
+import org.ajax4jsf.component.QueueRegistry;
+import org.ajax4jsf.javascript.ScriptUtils;
/**
* This class used for determining what standard resources should be encoded(queue,
skinning etc.). Implements SystemEventListener
@@ -62,30 +59,10 @@
private static final String VALUE_ATTRIBBUTE = "value";
- private static final String BASIC = "basic";
-
- private static final String EXTENDED = "extended";
-
- private static final String ENABLE = "enable";
-
- private static final String CLASSES_ECSS = "_classes.ecss";
-
- private static final String ECSS = ".ecss";
-
- private static final String BOTH_ECSS = "_both.ecss";
-
private static final String HEAD = "head";
private static final String NAME_ATTRIBBUTE = "name";
- private static final String STYLESHEET_RENDERER =
"javax.faces.resource.Stylesheet";
-
- private boolean useStdControlsSkinning;
-
- private boolean useStdControlsSkinningClasses;
-
- private boolean extendedSkinningAllowed;
-
/*
* (non-Javadoc)
*
@@ -103,58 +80,10 @@
public void processEvent(SystemEvent event) throws AbortProcessingException {
if (event instanceof PreRenderViewEvent) {
- encodeSkinningResources();
encodeQueueResource();
}
}
- private void setUseStdControlsSkinning(boolean stdControlsSkinning) {
- this.useStdControlsSkinning = stdControlsSkinning;
- }
-
- private void setUseStdControlsSkinningClasses(boolean stdControlsSkinningClasses) {
- this.useStdControlsSkinningClasses = stdControlsSkinningClasses;
- }
-
- private void setExtendedSkinningAllowed(boolean extendedSkinningAllowed) {
- this.extendedSkinningAllowed = extendedSkinningAllowed;
- }
-
- private void initializeSkinningParameters(FacesContext context) {
- boolean extendedSkinningAllowed = true;
- String skinningLevel = ContextInitParameters.getSkinningLevel(context);
- if (skinningLevel != null && skinningLevel.length() > 0) {
- if (BASIC.equals(skinningLevel)) {
- extendedSkinningAllowed = false;
- } else if (!EXTENDED.equals(skinningLevel)) {
- throw new IllegalArgumentException("Value: " + skinningLevel +
" of "
- + ContextInitParameters.CONTROL_SKINNING_LEVEL[0] + " init
parameter is invalid! Only " + EXTENDED
- + ", " + BASIC + " can be used");
- }
- }
-
- this.setExtendedSkinningAllowed(extendedSkinningAllowed);
-
- boolean useStdControlsSkinning = false;
-
- String stdControlsSkinning =
ContextInitParameters.getStandartControlSkinningParameter(context);
- if (stdControlsSkinning != null) {
- useStdControlsSkinning = ENABLE.equals(stdControlsSkinning);
- }
-
- this.setUseStdControlsSkinning(useStdControlsSkinning);
-
- boolean useStdControlsSkinningClasses = true;
-
- String stdControlsSkinningClasses =
ContextInitParameters.getStandartControlSkinningClassesParameter(context);
- if (stdControlsSkinningClasses != null) {
- useStdControlsSkinningClasses = ENABLE.equals(stdControlsSkinningClasses);
- }
-
- this.setUseStdControlsSkinningClasses(useStdControlsSkinningClasses);
-
- }
-
private void encodeQueueResource() {
FacesContext context = FacesContext.getCurrentInstance();
if (QueueRegistry.getInstance(context).hasQueuesToEncode()) {
@@ -230,54 +159,6 @@
return firstElementAdded;
}
- private void encodeSkinningResources() {
- initializeSkinningParameters(FacesContext.getCurrentInstance());
- String resourceSuffix = findResourceSuffix();
-
- if (resourceSuffix != null) {
- encodeSkinningResource(BASIC, resourceSuffix);
-
- if (extendedSkinningAllowed) {
- encodeSkinningResource(EXTENDED, resourceSuffix);
- }
- }
- }
-
- private void encodeSkinningResource(String resourcePrefix, String resourceSuffix) {
- String basicPath = resourcePrefix.concat(resourceSuffix);
- String fullPath = basicPath.concat(CompiledCSSResource.getHash(basicPath));
- addSkinningResourceToView(basicPath, fullPath);
- }
-
- private String findResourceSuffix() {
- String resourceSuffix = null;
-
- if (useStdControlsSkinning) {
- if (useStdControlsSkinningClasses) {
- resourceSuffix = BOTH_ECSS;
- } else {
- resourceSuffix = ECSS;
- }
- } else {
- if (useStdControlsSkinningClasses) {
- resourceSuffix = CLASSES_ECSS;
- } else {
- // no resources
- }
- }
- return resourceSuffix;
- }
-
- private void addSkinningResourceToView(String basePath, String fullPath) {
- FacesContext context = FacesContext.getCurrentInstance();
- removeComponentResource(context, basePath);
- HashMap<String, Object> hashMap = new HashMap<String, Object>();
- hashMap.put(MARKER_ATTRIBBUTE, basePath);
- hashMap.put(NAME_ATTRIBBUTE, fullPath);
- addComponentResource(context, hashMap, STYLESHEET_RENDERER);
-
- }
-
private void addComponentResource(FacesContext context, Map<String, Object>
params, String rendererType){
UIOutput output = new UIOutput();
if(rendererType != null){
Deleted: root/core/trunk/impl/src/main/java/org/richfaces/context/SingletonsContext.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/context/SingletonsContext.java 2010-05-20
23:27:53 UTC (rev 17171)
+++
root/core/trunk/impl/src/main/java/org/richfaces/context/SingletonsContext.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -1,47 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.context;
-
-import javax.faces.context.FacesContext;
-import java.util.Map;
-
-/**
- * @author Nick Belaevski
- * @since 4.0
- */
-public final class SingletonsContext {
- public static final ContextProvider APPLICATION = new
ContextProvider("Application") {
- @Override
- protected Map<String, Object> getContextMap(FacesContext facesContext) {
- return facesContext.getExternalContext().getApplicationMap();
- }
- };
- public static final ContextProvider FACES_CONTEXT = new
ContextProvider("FacesContext") {
- @Override
- protected Map<? super String, Object> getContextMap(FacesContext
facesContext) {
- return facesContext.getAttributes();
- }
- };
-
- private SingletonsContext() {
- }
-}
Added:
root/core/trunk/impl/src/main/java/org/richfaces/context/SkinningResourcesPhaseListener.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/context/SkinningResourcesPhaseListener.java
(rev 0)
+++
root/core/trunk/impl/src/main/java/org/richfaces/context/SkinningResourcesPhaseListener.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.context;
+
+import java.util.Map;
+
+import javax.el.ELContext;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.ajax4jsf.context.ContextInitParameters;
+import org.richfaces.el.BaseReadOnlyValueExpression;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class SkinningResourcesPhaseListener implements PhaseListener {
+
+ private static final long serialVersionUID = 7430448731396547419L;
+
+ private static final String RESOURCES_PROCESSED_MARKER =
SkinningResourcesPhaseListener.class.getName();
+
+ private static final String CLASSES_ECSS = "_classes.ecss";
+
+ private static final String ECSS = ".ecss";
+
+ private static final String BOTH_ECSS = "_both.ecss";
+
+ private static final String BASIC_CONTROLS;
+
+ private static final String BASIC_BOTH;
+
+ private static final String BASIC_CLASSES;
+
+ private static final String STYLESHEET_RENDERER =
"javax.faces.resource.Stylesheet";
+
+ static {
+ String basicName = "basic";
+
+ BASIC_CONTROLS = basicName + ECSS;
+ BASIC_BOTH = basicName + BOTH_ECSS;
+ BASIC_CLASSES = basicName + CLASSES_ECSS;
+
+ }
+
+ private static final class BasicResourceName extends BaseReadOnlyValueExpression {
+
+ private static final long serialVersionUID = 7520575496522682120L;
+
+ public BasicResourceName() {
+ super(String.class);
+ }
+
+ @Override
+ public Object getValue(ELContext context) {
+ FacesContext facesContext = getFacesContext(context);
+
+ boolean controls =
ContextInitParameters.isStandardControlSkinningEnabled(facesContext);
+ boolean classes =
ContextInitParameters.isStandardControlSkinningClassesEnabled(facesContext);
+
+ if (controls && classes) {
+ return BASIC_BOTH;
+ }
+
+ if (classes) {
+ return BASIC_CLASSES;
+ }
+
+ return BASIC_CONTROLS;
+ }
+
+ }
+
+ private static final class BasicResourceRendered extends BaseReadOnlyValueExpression
{
+
+ private static final long serialVersionUID = -1579256471133808739L;
+
+ public BasicResourceRendered() {
+ super(Boolean.TYPE);
+ }
+
+ @Override
+ public Object getValue(ELContext context) {
+ FacesContext facesContext = getFacesContext(context);
+
+ return ContextInitParameters.isStandardControlSkinningEnabled(facesContext)
||
+
ContextInitParameters.isStandardControlSkinningClassesEnabled(facesContext);
+ }
+
+ }
+
+ private UIComponent createComponentResource(FacesContext context) {
+ UIComponent resourceComponent =
context.getApplication().createComponent(UIOutput.COMPONENT_TYPE);
+ resourceComponent.setRendererType(STYLESHEET_RENDERER);
+ return resourceComponent;
+ }
+
+ public void afterPhase(PhaseEvent event) {
+ //not used
+ }
+
+ public void beforePhase(PhaseEvent event) {
+ //it's important for skinning resources to come *before* any users/components
stylesheet,
+ //that's why they are added via phase listener
+
+ FacesContext context = event.getFacesContext();
+ UIViewRoot viewRoot = context.getViewRoot();
+
+ assert viewRoot != null;
+
+ Map<String, Object> attributes = viewRoot.getAttributes();
+ if (!Boolean.TRUE.equals(attributes.get(RESOURCES_PROCESSED_MARKER))) {
+ attributes.put(RESOURCES_PROCESSED_MARKER, Boolean.TRUE);
+
+ UIComponent basic = createComponentResource(context);
+ basic.setValueExpression("name", new BasicResourceName());
+ basic.setValueExpression("rendered", new BasicResourceRendered());
+
+ viewRoot.addComponentResource(context, basic);
+ }
+ }
+
+ public PhaseId getPhaseId() {
+ return PhaseId.RENDER_RESPONSE;
+ }
+}
Added:
root/core/trunk/impl/src/main/java/org/richfaces/el/BaseReadOnlyValueExpression.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/el/BaseReadOnlyValueExpression.java
(rev 0)
+++
root/core/trunk/impl/src/main/java/org/richfaces/el/BaseReadOnlyValueExpression.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.el;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class BaseReadOnlyValueExpression extends ValueExpression {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1094028009026806965L;
+
+ private Class<?> type;
+
+ public BaseReadOnlyValueExpression(Class<?> type) {
+ super();
+ this.type = type;
+ }
+
+ @Override
+ public Class<?> getExpectedType() {
+ return type;
+ }
+
+ @Override
+ public Class<?> getType(ELContext context) {
+ return type;
+ }
+
+ @Override
+ public abstract Object getValue(ELContext context);
+
+ @Override
+ public boolean isReadOnly(ELContext context) {
+ return true;
+ }
+
+ @Override
+ public void setValue(ELContext context, Object value) {
+ throw new UnsupportedOperationException("setValue(ELContext,
Object)");
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ @Override
+ public String getExpressionString() {
+ return null;
+ }
+
+ @Override
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ @Override
+ public boolean isLiteralText() {
+ return false;
+ }
+
+ protected FacesContext getFacesContext(ELContext elContext) {
+ return (FacesContext) elContext.getContext(FacesContext.class);
+ }
+}
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2010-05-20
23:27:53 UTC (rev 17171)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -41,7 +41,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.resource.InternetResource;
-import org.richfaces.context.SingletonsContext;
+import org.richfaces.application.ServiceTracker;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.util.Util;
import org.slf4j.Logger;
@@ -94,8 +94,7 @@
// TODO - originally lastModified was set during resource creation.
// as resources can be managed beans this approach does not seem good
if (lastModified == null) {
- lastModified = (Date)
SingletonsContext.APPLICATION.get(context).getAttribute(
- ResourceHandlerImpl.HANDLER_START_TIME_ATTRIBUTE);
+ lastModified = ServiceTracker.getStartTime(context);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2010-05-20
23:27:53 UTC (rev 17171)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2010-05-21
12:58:49 UTC (rev 17172)
@@ -45,8 +45,6 @@
import org.ajax4jsf.cache.CacheManager;
import org.ajax4jsf.resource.Java2Dresource;
import org.richfaces.application.ServiceTracker;
-import org.richfaces.context.AttributesContext;
-import org.richfaces.context.SingletonsContext;
import org.richfaces.log.RichfacesLogger;
import org.richfaces.util.Util;
import org.richfaces.util.RequestStateManager.BooleanRequestStateVariable;
@@ -93,7 +91,6 @@
FacesContext facesContext = FacesContext.getCurrentInstance();
initializeCache(facesContext);
- markStartTime(facesContext);
}
private void initializeCache(FacesContext facesContext) {
@@ -102,12 +99,6 @@
cache = CacheManager.getInstance().getNewCache(RESOURCE_CACHE_NAME, envMap);
}
- private static void markStartTime(FacesContext facesContext) {
- AttributesContext applicationContext =
SingletonsContext.APPLICATION.get(facesContext);
-
- applicationContext.setAttribute(HANDLER_START_TIME_ATTRIBUTE, new Date());
- }
-
protected static void setResourceCodec(ResourceCodec codec) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Modified: root/core/trunk/impl/src/main/resources/META-INF/resources/basic.ecss
===================================================================
--- root/core/trunk/impl/src/main/resources/META-INF/resources/basic.ecss 2010-05-20
23:27:53 UTC (rev 17171)
+++ root/core/trunk/impl/src/main/resources/META-INF/resources/basic.ecss 2010-05-21
12:58:49 UTC (rev 17172)
@@ -1,3 +1,5 @@
+/* basic skinning styles */
+
input, select, textarea, button, keygen, isindex, legend, a {
font-size : '#{richSkin.generalSizeFont}';
font-family : '#{richSkin.generalFamilyFont}';
@@ -22,4 +24,52 @@
}
a:visited {
color : '#{richSkin.visitedLinkColor}';
+}
+
+/* extended skinning styles */
+
+input, select, textarea, button, keygen, isindex {
+ border-width: 1px;
+ border-color: '#{richSkin.panelBorderColor}';
+ color: '#{richSkin.controlTextColor}';
+}
+
+button, input[type="reset"], input[type="submit"],
input[type="button"] {
+ border-width: 1px;
+ border-color: '#{richSkin.panelBorderColor}';
+
+ font-size: '#{richSkin.generalSizeFont}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ color: '#{richSkin.headerTextColor}';
+
+ background-repeat: repeat-x;
+ background-position: top left;
+ background-color: '#{richSkin.headerBackgroundColor}';
+ background-image:
"url(#{resource['org.richfaces.renderkit.html.images.ButtonBackgroundImage']})";
+}
+
+button[disabled], input[type="reset"][disabled],
input[type="submit"][disabled], input[type="button"][disabled] {
+ color: '#{richSkin.tabDisabledTextColor}';
+ border-color: '#{richSkin.tableFooterBackgroundColor}';
+ background-color: '#{richSkin.tableFooterBackgroundColor}';
+ background-image:
"url(#{resource['org.richfaces.renderkit.html.images.ButtonDisabledBackgroundImage']})";
+}
+
+textarea, input[type="text"], input[type="password"], select {
+ border-width: 1px;
+ border-style: inset;
+ border-color: '#{richSkin.panelBorderColor}';
+
+ font-size: '#{richSkin.generalSizeFont}';
+ font-family: '#{richSkin.generalFamilyFont}';
+ color: '#{richSkin.controlTextColor}';
+
+ background-repeat: no-repeat;
+ background-position: 1px 1px;
+ background-color: '#{richSkin.controlBackgroundColor}';
+ background-image:
"url(#{resource['org.richfaces.renderkit.html.images.InputBackgroundImage']})";
+}
+
+textarea[disabled], input[type="text"][disabled],
input[type="password"][disabled], select[disabled] {
+ color: '#{richSkin.panelBorderColor}';
}
\ No newline at end of file
Modified: root/core/trunk/impl/src/main/resources/META-INF/resources/basic_classes.ecss
===================================================================
---
root/core/trunk/impl/src/main/resources/META-INF/resources/basic_classes.ecss 2010-05-20
23:27:53 UTC (rev 17171)
+++
root/core/trunk/impl/src/main/resources/META-INF/resources/basic_classes.ecss 2010-05-21
12:58:49 UTC (rev 17172)
@@ -1,3 +1,5 @@
+/* basic skinning styles */
+
.rich-container input, .rich-input, .rich-container select, .rich-select,
.rich-container textarea, .rich-textarea, .rich-container button, .rich-button,
.rich-container keygen, .rich-keygen,.rich-container isindex, .rich-isindex,
@@ -346,4 +348,78 @@
.rich-gradient-button{
background-image :
"url(#{resource['org.richfaces.renderkit.html.gradientimages.ButtonGradientImage']})";
background-repeat : repeat-x;
+}
+
+/* extended skinning styles */
+
+.rich-container input, .rich-input,
+.rich-container select, .rich-select,
+.rich-container textarea, .rich-textarea,
+.rich-container button, .rich-button,
+.rich-container keygen, .rich-keygen,
+.rich-container isindex, .rich-isindex {
+ border-width:1px;
+ border-color:'#{richSkin.panelBorderColor}';
+ color:'#{richSkin.controlTextColor}';
+}
+
+.rich-container button, .rich-button,
+.rich-button-button,
+.rich-button-reset,
+.rich-button-submit,
+.rich-container input[type="reset"], .rich-input-reset,
+.rich-container input[type="submit"], .rich-input-submit,
+.rich-container input[type="button"], .rich-input-button {
+ border-width: 1px;
+ border-color:'#{richSkin.panelBorderColor}';
+
+ background-repeat : repeat-x;
+ background-position : top left;
+ background-color:'#{richSkin.headerBackgroundColor}';
+ background-image:"url(#{resource['org.richfaces.renderkit.html.images.ButtonBackgroundImage']})";
+
+ font-size:'#{richSkin.generalSizeFont}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ color:'#{richSkin.headerTextColor}';
+}
+
+.rich-container button[disabled], .rich-button-disabled,
+.rich-button-button-disabled,
+.rich-button-reset-disabled,
+.rich-button-submit-disabled,
+.rich-container input[type="reset"][disabled], .rich-input-reset-disabled,
+.rich-container input[type="submit"][disabled], .rich-input-submit-disabled,
+.rich-container input[type="button"][disabled], .rich-input-button-disabled {
+ color:'#{richSkin.tabDisabledTextColor}';
+ background-color:'#{richSkin.tableFooterBackgroundColor}';
+ border-color:'#{richSkin.tableFooterBackgroundColor}';
+ background-image:"url(#{resource['org.richfaces.renderkit.html.images.ButtonDisabledBackgroundImage']})";
+}
+
+
+.rich-container textarea, .rich-textarea,
+.rich-textarea-textarea,
+.rich-container input[type="text"], .rich-input-text,
+.rich-container input[type="password"], .rich-input-password,
+.rich-container select, .rich-select {
+ border-width: 1px;
+ border-style : inset;
+ border-color:'#{richSkin.panelBorderColor}';
+
+ background-repeat : no-repeat;
+ background-position : 1px 1px;
+ background-color:'#{richSkin.controlBackgroundColor}';
+ background-image:"url(#{resource['org.richfaces.renderkit.html.images.InputBackgroundImage']})";
+
+ font-size:'#{richSkin.generalSizeFont}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ color:'#{richSkin.controlTextColor}';
+}
+
+.rich-container textarea[disabled], .rich-textarea-disabled,
+.rich-textarea-textarea-disabled,
+.rich-container input[type="text"][disabled], .rich-input-text-disabled,
+.rich-container input[type="password"][disabled],
.rich-input-password-disabled,
+.rich-container select[disabled], .rich-select-disabled {
+ color:'#{richSkin.panelBorderColor}';
}
\ No newline at end of file
Added:
root/core/trunk/impl/src/main/resources/META-INF/skinning-resources-listener.faces-config.xml
===================================================================
---
root/core/trunk/impl/src/main/resources/META-INF/skinning-resources-listener.faces-config.xml
(rev 0)
+++
root/core/trunk/impl/src/main/resources/META-INF/skinning-resources-listener.faces-config.xml 2010-05-21
12:58:49 UTC (rev 17172)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
version="2.0">
+ <name>richfaces</name>
+ <lifecycle>
+ <phase-listener>org.richfaces.context.SkinningResourcesPhaseListener</phase-listener>
+ </lifecycle>
+</faces-config>
\ No newline at end of file