Author: nbelaevski
Date: 2010-07-27 07:43:27 -0400 (Tue, 27 Jul 2010)
New Revision: 18241
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java
Log:
Updates & fixes for dynamic resources handling
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-07-27
11:42:34 UTC (rev 18240)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/AbstractBaseResource.java 2010-07-27
11:43:27 UTC (rev 18241)
@@ -54,7 +54,6 @@
protected AbstractBaseResource() {
super();
- this.setResourceName(getClass().getName());
}
// TODO remove FacesContext argument?
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java 2010-07-27
11:42:34 UTC (rev 18240)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java 2010-07-27
11:43:27 UTC (rev 18241)
@@ -68,11 +68,21 @@
public String getLibraryName() {
return sourceResource.getLibraryName();
}
+
+ @Override
+ public void setLibraryName(String libraryName) {
+ sourceResource.setLibraryName(libraryName);
+ }
@Override
public String getResourceName() {
return sourceResource.getResourceName();
}
+
+ @Override
+ public void setResourceName(String resourceName) {
+ sourceResource.setResourceName(resourceName);
+ }
public InputStream getResourceInputStream() throws IOException {
return sourceResource.getInputStream();
@@ -111,7 +121,7 @@
if (styleSheet != null) {
// TODO nick - handle encoding
String encoding = ctx.getExternalContext().getResponseCharacterEncoding();
- CSSVisitorImpl cssVisitor = new CSSVisitorImpl();
+ CSSVisitorImpl cssVisitor = new CSSVisitorImpl(ctx);
cssVisitor.setEncoding(encoding != null ? encoding : "UTF-8");
cssVisitor.visitStyleSheet(styleSheet);
Modified:
root/core/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java 2010-07-27
11:42:34 UTC (rev 18240)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java 2010-07-27
11:43:27 UTC (rev 18241)
@@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.el.ValueExpression;
import javax.faces.application.Resource;
import javax.faces.context.FacesContext;
@@ -59,12 +58,19 @@
private static final String NEW_LINE = "\r\n";
+ private FacesContext facesContext;
+
private String encoding;
private StringBuilder buffer = new StringBuilder();
private List<String> prefixes = new ArrayList<String>(2);
+ public CSSVisitorImpl(FacesContext facesContext) {
+ super();
+ this.facesContext = facesContext;
+ }
+
private void appendCSSText(CSSRule rule) {
String cssText = rule.getCssText().trim();
@@ -121,8 +127,7 @@
String resourceName = rule.getHref();
if (ELUtils.isValueReference(resourceName)) {
if (resourceName.indexOf(RESOURCE_START_PREFIX) == -1) {
- ValueExpression ex = ELUtils.createValueExpression(resourceName);
- resourceName = ELUtils.evaluateValueExpression(ex,
FacesContext.getCurrentInstance().getELContext()).toString();
+ resourceName =
facesContext.getApplication().evaluateExpressionGet(facesContext, resourceName,
String.class);
} else {
int start = resourceName.indexOf(RESOURCE_START_PREFIX) +
RESOURCE_START_PREFIX.length();
int end = resourceName.lastIndexOf("]");
@@ -130,7 +135,7 @@
resourceName = resourceName.replaceAll("\"",
"").replaceAll("'", "").trim();
}
}
- Resource imported = FacesContext.getCurrentInstance().getApplication().
+ Resource imported = facesContext.getApplication().
getResourceHandler().createResource(resourceName);
if (imported == null) {
LOGGER.error("Resource with name " + resourceName + "can't
be found.");
@@ -215,8 +220,7 @@
String value = styleDeclaration.getPropertyValue(propertyName).trim();
String priority = styleDeclaration.getPropertyPriority(propertyName);
if (ELUtils.isValueReference(value)) {
- ValueExpression ex = ELUtils.createValueExpression(value);
- value = ELUtils.evaluateValueExpression(ex,
FacesContext.getCurrentInstance().getELContext()).toString();
+ value = facesContext.getApplication().evaluateExpressionGet(facesContext,
value, String.class);
}
if (value.startsWith("\"") &&
value.endsWith("\"")) {
value = value.substring(1, value.length() - 1);
Show replies by date