Author: nbelaevski
Date: 2008-04-17 17:03:40 -0400 (Thu, 17 Apr 2008)
New Revision: 7909
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinImpl.java
trunk/framework/impl/src/main/resources/META-INF/skins/emeraldTown.skin.properties
trunk/framework/impl/src/main/resources/META-INF/skins/ruby.skin.properties
Log:
Fixed dynamic change of BASE_SKIN
Fixed several NPEs on plain skin
Gradient types reverted back to plain
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2008-04-17
19:32:43 UTC (rev 7908)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSRenderer.java 2008-04-17
21:03:40 UTC (rev 7909)
@@ -157,8 +157,10 @@
TemplateContext templateContext = new TemplateContext(null,context,component);
Object value = template.getValue(templateContext);
if(null == value){
- int hashCode = SkinFactory.getInstance().getSkin(context).hashCode(context);
- value = ByteBuffer.allocate(4).putInt(hashCode).array();
+ SkinFactory skinFactory = SkinFactory.getInstance();
+ int hashCode = skinFactory.getSkin(context).hashCode(context);
+ int baseHashCode = skinFactory.getBaseSkin(context).hashCode(context);
+ value = ByteBuffer.allocate(4*2).putInt(hashCode).putInt(baseHashCode).array();
}
return value;
}
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2008-04-17
19:32:43 UTC (rev 7908)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2008-04-17
21:03:40 UTC (rev 7909)
@@ -183,9 +183,11 @@
}
protected void restoreData(Data data, Zipper2 zipper2) {
- data.headerBackgroundColor = new Integer(zipper2.nextIntColor());
- data.headerGradientColor = new Integer(zipper2.nextIntColor());
- data.gradientType = GradientType.values()[zipper2.nextByte()];
+ if (zipper2.hasMore()) {
+ data.headerBackgroundColor = new Integer(zipper2.nextIntColor());
+ data.headerGradientColor = new Integer(zipper2.nextIntColor());
+ data.gradientType = GradientType.values()[zipper2.nextByte()];
+ }
}
protected Object deserializeData(byte[] objectArray) {
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2008-04-17
19:32:43 UTC (rev 7908)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2008-04-17
21:03:40 UTC (rev 7909)
@@ -93,8 +93,10 @@
}
protected void restoreData(org.richfaces.renderkit.html.BaseGradient.Data data,
Zipper2 zipper2) {
- ((Data) data).height = zipper2.nextInt();
- super.restoreData(data, zipper2);
+ if (zipper2.hasMore()) {
+ ((Data) data).height = zipper2.nextInt();
+ super.restoreData(data, zipper2);
+ }
}
protected static class Data extends BaseGradient.Data {
@@ -109,7 +111,7 @@
@Override
public byte[] toByteArray() {
byte[] bs = super.toByteArray();
- byte[] result = new byte[bs.length + 4];
+ byte[] result = new byte[(bs != null ? bs.length : 0) + 4];
new Zipper2(result).addInt(height).addBytes(bs);
return result;
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2008-04-17
19:32:43 UTC (rev 7908)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2008-04-17
21:03:40 UTC (rev 7909)
@@ -28,6 +28,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.resource.GifRenderer;
+import org.ajax4jsf.resource.InternetResourceBase;
import org.ajax4jsf.resource.InternetResourceBuilder;
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.resource.ResourceContext;
@@ -88,10 +89,14 @@
basicColor = getColorValueParameter(context, basicColorParamName);
}
- retVal = new byte[3 * 1];
- new Zipper2(retVal).addColor(basicColor);
+ if (basicColor != null) {
+ retVal = new byte[3 * 1];
+ new Zipper2(retVal).addColor(basicColor);
- return retVal;
+ return retVal;
+ } else {
+ return null;
+ }
}
/**
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/skin/SkinImpl.java 2008-04-17
19:32:43 UTC (rev 7908)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinImpl.java 2008-04-17
21:03:40 UTC (rev 7909)
@@ -24,7 +24,10 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
@@ -40,8 +43,11 @@
public static final String RENDER_KIT_PARAMETER = "render.kit";
+
+ @Deprecated
+ public static final String REQUEST_HASH_CODE_PARAMETER =
"org.ajax4jsf.skin.HASH_CODE";
- public static final String REQUEST_HASH_CODE_PARAMETER =
"org.ajax4jsf.skin.HASH_CODE";
+ public static final String REQUEST_HASH_CODES_MAP_PARAMETER =
"org.ajax4jsf.skin.HASH_CODES_MAP";
private Map skinParams = new HashMap();
@@ -116,19 +122,31 @@
* @see org.richfaces.skin.Skin#hashCode(javax.faces.context.FacesContext)
*/
public int hashCode(FacesContext context) {
- Integer requestCode = (Integer)
context.getExternalContext().getRequestMap().get(REQUEST_HASH_CODE_PARAMETER);
- if(null == requestCode){
- int hash = 0;
- for (Iterator iter = skinParams.keySet().iterator(); iter.hasNext();) {
- String key = (String) iter.next();
- Object parameter = getParameter(context,key);
- hash = 31*hash + (parameter != null ? parameter.hashCode() : 0);
- }
- requestCode = new Integer(hash);
- // store hash for this skin as request-skope parameter - not calculate on next calls
for same request
- context.getExternalContext().getRequestMap().put(REQUEST_HASH_CODE_PARAMETER,requestCode);
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
+ ConcurrentMap<Skin, Integer> map;
+ synchronized (requestMap) {
+ map = (ConcurrentMap<Skin, Integer>)
requestMap.get(REQUEST_HASH_CODES_MAP_PARAMETER);
+ if (map == null) {
+ map = new ConcurrentHashMap<Skin, Integer>();
+ requestMap.put(REQUEST_HASH_CODES_MAP_PARAMETER, map);
}
- return requestCode.intValue();
+ }
+
+ Integer requestCode = (Integer) map.get(this);
+ if(null == requestCode){
+ int hash = 0;
+ for (Iterator iter = skinParams.keySet().iterator(); iter.hasNext();) {
+ String key = (String) iter.next();
+ Object parameter = getParameter(context,key);
+ hash = 31*hash + key.hashCode();
+ hash = 31*hash + (parameter != null ? parameter.hashCode() : 0);
+ }
+ requestCode = new Integer(hash);
+ // store hash for this skin as request-skope parameter - not calculate on next calls
for same request
+ map.putIfAbsent(this, requestCode);
+ }
+ return requestCode.intValue();
}
Modified:
trunk/framework/impl/src/main/resources/META-INF/skins/emeraldTown.skin.properties
===================================================================
---
trunk/framework/impl/src/main/resources/META-INF/skins/emeraldTown.skin.properties 2008-04-17
19:32:43 UTC (rev 7908)
+++
trunk/framework/impl/src/main/resources/META-INF/skins/emeraldTown.skin.properties 2008-04-17
21:03:40 UTC (rev 7909)
@@ -70,4 +70,4 @@
editBackgroundColor=#FEFFDA
#Gradients
-gradientType=glass
+gradientType=plain
Modified: trunk/framework/impl/src/main/resources/META-INF/skins/ruby.skin.properties
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/skins/ruby.skin.properties 2008-04-17
19:32:43 UTC (rev 7908)
+++ trunk/framework/impl/src/main/resources/META-INF/skins/ruby.skin.properties 2008-04-17
21:03:40 UTC (rev 7909)
@@ -71,4 +71,4 @@
editBackgroundColor=#FEFFDA
#Gradients
-gradientType=plastic
+gradientType=plain