Author: nbelaevski
Date: 2010-05-21 10:10:54 -0400 (Fri, 21 May 2010)
New Revision: 17175
Added:
root/examples/core-demo/trunk/src/main/webapp/skinning.xhtml
Modified:
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
root/examples/core-demo/trunk/src/main/java/org/richfaces/demo/SkinBean.java
root/examples/core-demo/trunk/src/main/webapp/WEB-INF/web.xml
root/examples/core-demo/trunk/src/main/webapp/welcome.xhtml
Log:
https://jira.jboss.org/browse/RF-8672
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-05-21
13:15:51 UTC (rev 17174)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java 2010-05-21
14:10:54 UTC (rev 17175)
@@ -25,10 +25,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.ByteBuffer;
import java.text.MessageFormat;
import javax.faces.application.ProjectStage;
import javax.faces.application.Resource;
+import javax.faces.component.StateHolder;
import javax.faces.context.FacesContext;
import org.richfaces.log.RichfacesLogger;
@@ -47,7 +49,7 @@
/**
* @author amarkhel Class, that represented dynamic CSS resource.
*/
-public class CompiledCSSResource extends AbstractBaseResource {
+public class CompiledCSSResource extends AbstractBaseResource implements StateHolder {
private static final String ECSS = ".ecss";
@@ -159,16 +161,11 @@
return "text/css";
}
- public static String getHash(String path) {
- return Integer.toHexString(getSkinHashCode());
+ private static int getSkinHashCode(FacesContext context) {
+ Skin skin = SkinFactory.getInstance().getSkin(context);
+ return skin.hashCode(context);
}
- private static int getSkinHashCode() {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Skin skin = SkinFactory.getInstance().getSkin(facesContext);
- return skin.hashCode(facesContext);
- }
-
@Override
public boolean userAgentNeedsUpdate(FacesContext context) {
// TODO nick - review
@@ -234,4 +231,22 @@
}
}
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ //do nothing
+ }
+
+ public Object saveState(FacesContext context) {
+ ByteBuffer buffer = ByteBuffer.allocate(4);
+ buffer.putInt(getSkinHashCode(context));
+ return buffer.array();
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ //do nothing
+ }
}
\ No newline at end of file
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-05-21
13:15:51 UTC (rev 17174)
+++
root/core/trunk/impl/src/main/java/org/richfaces/resource/css/CSSVisitorImpl.java 2010-05-21
14:10:54 UTC (rev 17175)
@@ -46,7 +46,6 @@
import org.w3c.dom.css.CSSStyleSheet;
import org.w3c.dom.css.CSSUnknownRule;
import org.w3c.dom.stylesheets.MediaList;
-import org.richfaces.resource.CompiledCSSResource;
/**
* @author Nick Belaevski
@@ -131,9 +130,6 @@
resourceName = resourceName.replaceAll("\"",
"").replaceAll("'", "").trim();
}
}
- if (resourceName.indexOf(".ecss") != -1) {
- resourceName = resourceName + CompiledCSSResource.getHash(resourceName);
- }
Resource imported = FacesContext.getCurrentInstance().getApplication().
getResourceHandler().createResource(resourceName);
if (imported == null) {
Modified: root/examples/core-demo/trunk/src/main/java/org/richfaces/demo/SkinBean.java
===================================================================
---
root/examples/core-demo/trunk/src/main/java/org/richfaces/demo/SkinBean.java 2010-05-21
13:15:51 UTC (rev 17174)
+++
root/examples/core-demo/trunk/src/main/java/org/richfaces/demo/SkinBean.java 2010-05-21
14:10:54 UTC (rev 17175)
@@ -2,12 +2,31 @@
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
+import javax.faces.model.SelectItem;
@ManagedBean(name = "skinBean")
@SessionScoped
public class SkinBean {
+
+ private SelectItem[] skinSetItems = {
+ new SelectItem("blueSky"),
+ new SelectItem("classic"),
+ new SelectItem("deepMarine"),
+ new SelectItem("DEFAULT"),
+ new SelectItem("emeraldTown"),
+ new SelectItem("japanCherry"),
+ new SelectItem("NULL"),
+ new SelectItem("plain"),
+ new SelectItem("ruby"),
+ new SelectItem("wine")
+ };
+
private String skin = "classic";
+ private boolean enableElementsSkinning = true;
+
+ private boolean enableClassesSkinning = false;
+
public String getSkin() {
return skin;
}
@@ -15,4 +34,24 @@
public void setSkin(String skin) {
this.skin = skin;
}
+
+ public boolean isEnableElementsSkinning() {
+ return enableElementsSkinning;
+ }
+
+ public void setEnableElementsSkinning(boolean enableElementsSkinning) {
+ this.enableElementsSkinning = enableElementsSkinning;
+ }
+
+ public boolean isEnableClassesSkinning() {
+ return enableClassesSkinning;
+ }
+
+ public void setEnableClassesSkinning(boolean enableClassesSkinning) {
+ this.enableClassesSkinning = enableClassesSkinning;
+ }
+
+ public SelectItem[] getSkinSetItems() {
+ return skinSetItems;
+ }
}
Modified: root/examples/core-demo/trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- root/examples/core-demo/trunk/src/main/webapp/WEB-INF/web.xml 2010-05-21 13:15:51 UTC
(rev 17174)
+++ root/examples/core-demo/trunk/src/main/webapp/WEB-INF/web.xml 2010-05-21 14:10:54 UTC
(rev 17175)
@@ -14,8 +14,23 @@
<param-name>org.richfaces.SKIN</param-name>
<param-value>#{skinBean.skin}</param-value>
</context-param>
+
+ <context-param>
+ <param-name>org.richfaces.CONTROL_SKINNING</param-name>
+ <param-value>#{skinBean.enableElementsSkinning ? 'enable' :
''}</param-value>
+ </context-param>
<context-param>
+ <param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
+ <param-value>#{skinBean.enableClassesSkinning ? 'enable' :
''}</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>client</param-value>
+ </context-param>
+
+ <context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
Added: root/examples/core-demo/trunk/src/main/webapp/skinning.xhtml
===================================================================
--- root/examples/core-demo/trunk/src/main/webapp/skinning.xhtml
(rev 0)
+++ root/examples/core-demo/trunk/src/main/webapp/skinning.xhtml 2010-05-21 14:10:54 UTC
(rev 17175)
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+<f:view>
+ <h:head>
+ </h:head>
+ <h:body>
+ <h:form>
+ <h:outputLabel value="Select skin: " for="skinSelector" />
+ <h:selectOneRadio id="skinSelector" value="#{skinBean.skin}"
+ onclick="submit()">
+ <f:selectItems value="#{skinBean.skinSetItems}" />
+ </h:selectOneRadio>
+
+ <br />
+ <h:outputLabel value="Enable skinning via elements: "
+ for="skinViaElementsCheck" />
+ <h:selectBooleanCheckbox id="skinViaElementsCheck"
+ value="#{skinBean.enableElementsSkinning}" onclick="submit()"
/>
+ <br />
+ <h:outputLabel value="Enable skinning via classes: "
+ for="skinViaClassesCheck" />
+ <h:selectBooleanCheckbox id="skinViaClassesCheck"
+ value="#{skinBean.enableClassesSkinning}" onclick="submit()"
/>
+ <br />
+
+ <h:commandButton value="Apply" />
+ </h:form>
+
+ Skinned via elements:
+
+ <form>
+ <fieldset>
+ <legend>Legend</legend>
+
+ <button>Test</button>
+ <button disabled="disabled">Test disabled</button>
+
+ <input type="button" value="Test" />
+ <input disabled="disabled" type="button" value="Test
disabled" />
+
+ <input type="checkbox" name="check" />
+ <input type="checkbox" name="check"
checked="checked"/>
+ <input type="checkbox" name="check"
disabled="disabled"/>
+ <input type="checkbox" name="check"
checked="checked" disabled="disabled" />
+
+ <input type="file" />
+
+ <input type="radio" name="radio" />
+ <input type="radio" name="radio"
checked="checked"/>
+ <input type="radio" name="radio" disabled="disabled"
/>
+ <input type="radio" name="radio0" checked="checked"
disabled="disabled" />
+
+ <input type="text" value="Test" />
+ <input type="text" value="Test disabled"
disabled="disabled" />
+ <input type="text" value="Test readonly"
readonly="readonly"/>
+
+ <select size="1">
+ <option>Test</option>
+ <option>Test</option>
+ <option>Test</option>
+ <option>Test</option>
+ </select>
+ <select size="1" disabled="disabled">
+ <option>Test</option>
+ <option>Test</option>
+ <option>Test</option>
+ <option>Test</option>
+ </select>
+
+ <select multiple="multiple" size="4">
+ <option>Test</option>
+ <option>Test1</option>
+ <option>Test2</option>
+ <option>Test3</option>
+ </select>
+ <select multiple="multiple" size="4"
disabled="disabled">
+ <option>Test</option>
+ <option>Test1</option>
+ <option>Test2</option>
+ <option>Test3</option>
+ </select>
+
+ <br/><br/>
+ <textarea>text</textarea>
+ <textarea disabled="disabled">text disabled</textarea>
+ <textarea readonly="readonly">text readonly</textarea>
+
+ <keygen />
+ <keygen disabled="disabled" />
+ <br /><br />
+ <isindex />
+
+ <a href="#1">Link 1</a>
+ <br />
+ <a href="#2">Link 2</a>
+ </fieldset>
+ </form>
+ </h:body>
+</f:view>
+</html>
\ No newline at end of file
Modified: root/examples/core-demo/trunk/src/main/webapp/welcome.xhtml
===================================================================
--- root/examples/core-demo/trunk/src/main/webapp/welcome.xhtml 2010-05-21 13:15:51 UTC
(rev 17174)
+++ root/examples/core-demo/trunk/src/main/webapp/welcome.xhtml 2010-05-21 14:10:54 UTC
(rev 17175)
@@ -24,6 +24,7 @@
<li><h:link outcome="queue">a4j:queue</h:link></li>
<li><h:link
outcome="repeat">a4j:repeat</h:link></li>
<li><h:link
outcome="region">a4j:region</h:link></li>
+ <li><h:link outcome="skinning">controls
skinning</h:link></li>
</ul>
</center>
</h:body>