JBoss Rich Faces SVN: r18244 - root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-27 08:10:43 -0400 (Tue, 27 Jul 2010)
New Revision: 18244
Modified:
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
Log:
https://jira.jboss.org/browse/RF-8970
Modified: root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java
===================================================================
--- root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java 2010-07-27 11:54:17 UTC (rev 18243)
+++ root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPollRenderer.java 2010-07-27 12:10:43 UTC (rev 18244)
@@ -56,6 +56,15 @@
public static final String RENDERER_TYPE = "org.richfaces.PollRenderer";
private static final String AJAX_POLL_FUNCTION = "RichFaces.startPoll";
+ @Override
+ protected void queueComponentEventForBehaviorEvent(FacesContext context, UIComponent component, String eventName) {
+ super.queueComponentEventForBehaviorEvent(context, component, eventName);
+
+ if (AbstractPoll.TIMER.equals(eventName)) {
+ new ActionEvent(component).queue();
+ }
+ }
+
/*
* (non-Javadoc)
*
Modified: root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
--- root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-07-27 11:54:17 UTC (rev 18243)
+++ root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-07-27 12:10:43 UTC (rev 18244)
@@ -64,7 +64,7 @@
protected void queueComponentEventForBehaviorEvent(FacesContext context, UIComponent component, String eventName) {
super.queueComponentEventForBehaviorEvent(context, component, eventName);
- if (AbstractPush.DATA_AVAILABLE.equals(eventName) || AbstractPush.ON_DATA_AVAILABLE.equals(eventName)) {
+ if (AbstractPush.DATA_AVAILABLE.equals(eventName)) {
new ActionEvent(component).queue();
}
}
14 years, 5 months
JBoss Rich Faces SVN: r18243 - in root/tests/metamer/trunk/application/src/main/webapp: resources/css and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-07-27 07:54:17 -0400 (Tue, 27 Jul 2010)
New Revision: 18243
Added:
root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.ecss
root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.ecss
Removed:
root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.css
root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.css
Modified:
root/tests/metamer/trunk/application/src/main/webapp/index.xhtml
root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/attributes.xhtml
root/tests/metamer/trunk/application/src/main/webapp/templates/template.xhtml
Log:
* css style of lines in header and attributes dynamically changing according to selected skin
Modified: root/tests/metamer/trunk/application/src/main/webapp/index.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/index.xhtml 2010-07-27 11:45:44 UTC (rev 18242)
+++ root/tests/metamer/trunk/application/src/main/webapp/index.xhtml 2010-07-27 11:54:17 UTC (rev 18243)
@@ -5,7 +5,7 @@
<h:head>
<title>Metamer: RichFaces Testing Application</title>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
- <h:outputStylesheet library="css" name="common.css" />
+ <h:outputStylesheet library="css" name="common.ecss" />
<h:outputStylesheet library="css" name="list.css" />
</h:head>
Deleted: root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.css
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.css 2010-07-27 11:45:44 UTC (rev 18242)
+++ root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.css 2010-07-27 11:54:17 UTC (rev 18243)
@@ -1,29 +0,0 @@
-body {
- background: white;
-}
-
-.button {
- width: 100px;
- height: 21px;
-}
-
-.header .external-table {
- border-width: 0px;
- border-collapse: collapse;
- padding-bottom: 30px;
-}
-
-.header-column {
- border-width: 1px;
- padding: 5px;
- border-style: dotted;
- border-color: grey;
-}
-
-a img {
- border: 0px;
-}
-
-.valign-top {
- vertical-align: top;
-}
\ No newline at end of file
Added: root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.ecss
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.ecss (rev 0)
+++ root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.ecss 2010-07-27 11:54:17 UTC (rev 18243)
@@ -0,0 +1,29 @@
+body {
+ background: white;
+}
+
+.button {
+ width: 100px;
+ height: 21px;
+}
+
+.header .external-table {
+ border-width: 0px;
+ border-collapse: collapse;
+ padding-bottom: 30px;
+}
+
+.header-column {
+ border-width: 1px;
+ padding: 5px;
+ border-style: dotted;
+ border-color: '#{a4jSkin.panelBorderColor}';
+}
+
+a img {
+ border: 0px;
+}
+
+.valign-top {
+ vertical-align: top;
+}
\ No newline at end of file
Modified: root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/attributes.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/attributes.xhtml 2010-07-27 11:45:44 UTC (rev 18242)
+++ root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/attributes.xhtml 2010-07-27 11:54:17 UTC (rev 18243)
@@ -15,7 +15,7 @@
<composite:implementation>
- <h:outputStylesheet library="testapp/css" name="attributes.css" />
+ <h:outputStylesheet library="testapp/css" name="attributes.ecss" />
<h:panelGrid id="#{cc.attrs.id}" columns="#{cc.attrs.columns * 2}" styleClass="attributes"
columnClasses="attributes-first-column, attributes-second-column, attributes-first-column, attributes-second-column">
Deleted: root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.css
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.css 2010-07-27 11:45:44 UTC (rev 18242)
+++ root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.css 2010-07-27 11:54:17 UTC (rev 18243)
@@ -1,26 +0,0 @@
-.attributes {
- border-width: 0px;
- border-collapse: collapse;
-}
-
-.attributes-first-column {
- border-width: 1px;
- padding: 10px;
- border-style: dotted;
- border-color: grey;
- border-right: none;
-}
-
-.attributes-second-column {
- border-width: 1px;
- padding: 10px;
- padding-left: 0px;
- border-style: dotted;
- border-color: grey;
- border-left: none;
-}
-
-.attributes-second-column table input {
- margin-left: 0px;
-}
-
Copied: root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.ecss (from rev 18239, root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.css)
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.ecss (rev 0)
+++ root/tests/metamer/trunk/application/src/main/webapp/resources/testapp/css/attributes.ecss 2010-07-27 11:54:17 UTC (rev 18243)
@@ -0,0 +1,26 @@
+.attributes {
+ border-width: 0px;
+ border-collapse: collapse;
+}
+
+.attributes-first-column {
+ border-width: 1px;
+ padding: 10px;
+ border-style: dotted;
+ border-color: '#{a4jSkin.panelBorderColor}';
+ border-right: none;
+}
+
+.attributes-second-column {
+ border-width: 1px;
+ padding: 10px;
+ padding-left: 0px;
+ border-style: dotted;
+ border-color: '#{a4jSkin.panelBorderColor}';
+ border-left: none;
+}
+
+.attributes-second-column table input {
+ margin-left: 0px;
+}
+
Modified: root/tests/metamer/trunk/application/src/main/webapp/templates/template.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/templates/template.xhtml 2010-07-27 11:45:44 UTC (rev 18242)
+++ root/tests/metamer/trunk/application/src/main/webapp/templates/template.xhtml 2010-07-27 11:54:17 UTC (rev 18243)
@@ -5,7 +5,7 @@
<h:head>
<title><ui:insert name="pageTitle">Metamer</ui:insert></title>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
- <h:outputStylesheet library="css" name="common.css" />
+ <h:outputStylesheet library="css" name="common.ecss" />
<h:outputScript library="script" name="common.js" />
<ui:insert name="head"/>
</h:head>
14 years, 5 months
JBoss Rich Faces SVN: r18242 - in root/cdk-sandbox/trunk/dynamic-resources-prerenderer: src/main/java/org/richfaces/cdk and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-27 07:45:44 -0400 (Tue, 27 Jul 2010)
New Revision: 18242
Added:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceInfo.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ApplicationImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/CurrentResourceContext.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/VariableMapperImpl.java
Removed:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceProducerFactory.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ClassResourceProducer.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceProducerFactoryImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/URLResourceProducer.java
Modified:
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Faces.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/FileNameMapper.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourcesScanner.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ELContextImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/FacesContextImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/FacesImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java
root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java
Log:
Dynamic resources prerenderer: latest changes check-in
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/pom.xml 2010-07-27 11:45:44 UTC (rev 18242)
@@ -52,8 +52,6 @@
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
- <type>jar</type>
- <scope>compile</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
@@ -67,6 +65,11 @@
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.sun.el</groupId>
+ <artifactId>el-ri</artifactId>
+ <version>1.0</version>
+ </dependency>
</dependencies>
<build>
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Faces.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Faces.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Faces.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -21,6 +21,8 @@
*/
package org.richfaces.cdk;
+import javax.faces.context.FacesContext;
+
/**
* @author Nick Belaevski
*
@@ -33,7 +35,7 @@
public void setSkin(String skinName);
- public void startRequest();
+ public FacesContext startRequest();
public void stopRequest();
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/FileNameMapper.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/FileNameMapper.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/FileNameMapper.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -21,12 +21,14 @@
*/
package org.richfaces.cdk;
+import javax.faces.application.Resource;
+
/**
* @author Nick Belaevski
*
*/
public interface FileNameMapper {
- public String createName(String mimeType, String resourceName);
+ public String createName(Resource resource);
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/Main.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -21,12 +21,6 @@
*/
package org.richfaces.cdk;
-import static com.google.common.base.Predicates.notNull;
-import static com.google.common.collect.Collections2.filter;
-import static com.google.common.collect.Collections2.transform;
-
-import java.util.Collection;
-import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
@@ -35,7 +29,6 @@
import org.richfaces.cdk.faces.FacesImpl;
import org.richfaces.cdk.naming.FileNameMapperImpl;
-import org.richfaces.cdk.resource.ResourceProducerFactoryImpl;
import org.richfaces.cdk.resource.ResourceWriterImpl;
import org.richfaces.cdk.resource.ResourcesScannerImpl;
import org.richfaces.cdk.task.ResourceTaskFactoryImpl;
@@ -49,22 +42,12 @@
public class Main {
private static ExecutorService createExecutorService() {
- return Executors.newFixedThreadPool(4);
+ return Executors.newSingleThreadExecutor();
}
- private static <T> Collection<T> concatCollections(Collection<? extends T> firstCollection,
- Collection<? extends T> secondCollection) {
- List<T> result = Lists.newArrayList();
-
- result.addAll(firstCollection);
- result.addAll(secondCollection);
-
- return result;
- }
-
public static void main(String[] args) throws Exception {
// TODO set webroot
- Faces faces = new FacesImpl(null);
+ Faces faces = new FacesImpl(null, new FileNameMapperImpl());
faces.start();
String dstDir = args[0];
@@ -72,19 +55,10 @@
ResourcesScanner resourcesScanner = new ResourcesScannerImpl();
resourcesScanner.scan();
- ResourceProducerFactory resourceFactory = new ResourceProducerFactoryImpl();
-
- Collection<ResourceProducer> classResources = filter(
- transform(resourcesScanner.getClassResources(), resourceFactory.getClassResourceProducerFactory()), notNull());
- Collection<ResourceProducer> urlResources = filter(
- transform(resourcesScanner.getURLResources(), resourceFactory.getURLResourceProducerFactory()), notNull());
-
- Collection<ResourceProducer> resources = concatCollections(classResources, urlResources);
-
- ResourceWriterImpl resourceWriter = new ResourceWriterImpl(dstDir, new FileNameMapperImpl());
+ ResourceWriterImpl resourceWriter = new ResourceWriterImpl(dstDir);
ResourceTaskFactory taskFactory = new ResourceTaskFactoryImpl(faces, resourceWriter);
- taskFactory.setResources(resources);
+ taskFactory.setResources(resourcesScanner.getResources());
taskFactory.setSkins(Lists.newArrayList("blueSky", "ruby", "classic"));
ExecutorService executorService = createExecutorService();
@@ -102,7 +76,7 @@
completionService.take().get();
} catch (ExecutionException e) {
// TODO: handle exception
- //e.getCause().printStackTrace();
+ e.getCause().printStackTrace();
}
tasksCounter--;
}
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceInfo.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceInfo.java (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceInfo.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -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.cdk;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ResourceInfo {
+
+ public static final String CLASSPATH_RESOURCES_LOCATION = "META-INF/resources/";
+
+ private final String resourceName;
+
+ private final String libraryName;
+
+ public ResourceInfo(String resourceName) {
+ this(resourceName, null);
+ }
+
+ public ResourceInfo(String resourceName, String libraryName) {
+ super();
+ this.resourceName = resourceName;
+ this.libraryName = libraryName;
+ }
+
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public String getLibraryName() {
+ return libraryName;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((libraryName == null) ? 0 : libraryName.hashCode());
+ result = prime * result + ((resourceName == null) ? 0 : resourceName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ResourceInfo other = (ResourceInfo) obj;
+ if (libraryName == null) {
+ if (other.libraryName != null) {
+ return false;
+ }
+ } else if (!libraryName.equals(other.libraryName)) {
+ return false;
+ }
+ if (resourceName == null) {
+ if (other.resourceName != null) {
+ return false;
+ }
+ } else if (!resourceName.equals(other.resourceName)) {
+ return false;
+ }
+ return true;
+ }
+
+}
Deleted: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceProducerFactory.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceProducerFactory.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceProducerFactory.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -1,36 +0,0 @@
-/*
- * 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.cdk;
-
-import com.google.common.base.Function;
-
-/**
- * @author Nick Belaevski
- *
- */
-public interface ResourceProducerFactory {
-
- public Function<String, ResourceProducer> getURLResourceProducerFactory();
-
- public Function<Class<?>, ResourceProducer> getClassResourceProducerFactory();
-
-}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourceTaskFactory.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -32,7 +32,7 @@
public void setSkins(Collection<String> skins);
- public void setResources(Collection<ResourceProducer> resources);
+ public void setResources(Collection<ResourceInfo> resources);
public Collection<Callable<Object>> createTasks();
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourcesScanner.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourcesScanner.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/ResourcesScanner.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -33,7 +33,6 @@
public void scan();
- public Collection<Class<?>> getClassResources();
+ public Collection<ResourceInfo> getResources();
- public Collection<String> getURLResources();
}
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ApplicationImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ApplicationImpl.java (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ApplicationImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -0,0 +1,488 @@
+/*
+ * 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.cdk.faces;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Locale;
+
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.application.NavigationHandler;
+import javax.faces.application.ProjectStage;
+import javax.faces.application.ResourceHandler;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.ReferenceSyntaxException;
+import javax.faces.el.ValueBinding;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.ActionListener;
+import javax.faces.validator.Validator;
+
+import com.sun.el.ExpressionFactoryImpl;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ApplicationImpl extends Application {
+
+ private ExpressionFactory expressionFactory = createExpressionFactory();
+
+ private ResourceHandler resourceHandler = createResourceHandler();
+
+ private ExpressionFactory createExpressionFactory() {
+ return ExpressionFactoryImpl.newInstance();
+ }
+
+ private ResourceHandler createResourceHandler() {
+ return new ResourceHandlerImpl();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getActionListener()
+ */
+ @Override
+ public ActionListener getActionListener() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setActionListener(javax.faces.event.ActionListener)
+ */
+ @Override
+ public void setActionListener(ActionListener listener) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getDefaultLocale()
+ */
+ @Override
+ public Locale getDefaultLocale() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setDefaultLocale(java.util.Locale)
+ */
+ @Override
+ public void setDefaultLocale(Locale locale) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getDefaultRenderKitId()
+ */
+ @Override
+ public String getDefaultRenderKitId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setDefaultRenderKitId(java.lang.String)
+ */
+ @Override
+ public void setDefaultRenderKitId(String renderKitId) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getMessageBundle()
+ */
+ @Override
+ public String getMessageBundle() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setMessageBundle(java.lang.String)
+ */
+ @Override
+ public void setMessageBundle(String bundle) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getNavigationHandler()
+ */
+ @Override
+ public NavigationHandler getNavigationHandler() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setNavigationHandler(javax.faces.application.NavigationHandler)
+ */
+ @Override
+ public void setNavigationHandler(NavigationHandler handler) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getPropertyResolver()
+ */
+ @Override
+ public PropertyResolver getPropertyResolver() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setPropertyResolver(javax.faces.el.PropertyResolver)
+ */
+ @Override
+ public void setPropertyResolver(PropertyResolver resolver) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getVariableResolver()
+ */
+ @Override
+ public VariableResolver getVariableResolver() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setVariableResolver(javax.faces.el.VariableResolver)
+ */
+ @Override
+ public void setVariableResolver(VariableResolver resolver) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getViewHandler()
+ */
+ @Override
+ public ViewHandler getViewHandler() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setViewHandler(javax.faces.application.ViewHandler)
+ */
+ @Override
+ public void setViewHandler(ViewHandler handler) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getStateManager()
+ */
+ @Override
+ public StateManager getStateManager() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setStateManager(javax.faces.application.StateManager)
+ */
+ @Override
+ public void setStateManager(StateManager manager) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#addComponent(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void addComponent(String componentType, String componentClass) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#createComponent(java.lang.String)
+ */
+ @Override
+ public UIComponent createComponent(String componentType) throws FacesException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#createComponent(javax.faces.el.ValueBinding,
+ * javax.faces.context.FacesContext, java.lang.String)
+ */
+ @Override
+ public UIComponent createComponent(ValueBinding componentBinding, FacesContext context, String componentType)
+ throws FacesException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getComponentTypes()
+ */
+ @Override
+ public Iterator<String> getComponentTypes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#addConverter(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void addConverter(String converterId, String converterClass) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#addConverter(java.lang.Class, java.lang.String)
+ */
+ @Override
+ public void addConverter(Class<?> targetClass, String converterClass) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#createConverter(java.lang.String)
+ */
+ @Override
+ public Converter createConverter(String converterId) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#createConverter(java.lang.Class)
+ */
+ @Override
+ public Converter createConverter(Class<?> targetClass) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getConverterIds()
+ */
+ @Override
+ public Iterator<String> getConverterIds() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getConverterTypes()
+ */
+ @Override
+ public Iterator<Class<?>> getConverterTypes() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#createMethodBinding(java.lang.String, java.lang.Class<?>[])
+ */
+ @Override
+ public MethodBinding createMethodBinding(String ref, Class<?>[] params) throws ReferenceSyntaxException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getSupportedLocales()
+ */
+ @Override
+ public Iterator<Locale> getSupportedLocales() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#setSupportedLocales(java.util.Collection)
+ */
+ @Override
+ public void setSupportedLocales(Collection<Locale> locales) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#addValidator(java.lang.String, java.lang.String)
+ */
+ @Override
+ public void addValidator(String validatorId, String validatorClass) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#createValidator(java.lang.String)
+ */
+ @Override
+ public Validator createValidator(String validatorId) throws FacesException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getValidatorIds()
+ */
+ @Override
+ public Iterator<String> getValidatorIds() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#createValueBinding(java.lang.String)
+ */
+ @Override
+ public ValueBinding createValueBinding(String ref) throws ReferenceSyntaxException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ProjectStage getProjectStage() {
+ return ProjectStage.Development;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getExpressionFactory()
+ */
+ @Override
+ public ExpressionFactory getExpressionFactory() {
+ return expressionFactory;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.application.Application#getResourceHandler()
+ */
+ @Override
+ public ResourceHandler getResourceHandler() {
+ return resourceHandler;
+ }
+
+ @Override
+ public <T> T evaluateExpressionGet(FacesContext context, String expression, Class<? extends T> expectedType)
+ throws ELException {
+ ValueExpression ve = getExpressionFactory().createValueExpression(context.getELContext(), expression,
+ expectedType);
+ return (T) (ve.getValue(context.getELContext()));
+ }
+}
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/CurrentResourceContext.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/CurrentResourceContext.java (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/CurrentResourceContext.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -0,0 +1,61 @@
+/*
+ * 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.cdk.faces;
+
+import java.util.Map;
+
+import javax.faces.application.Resource;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+//TODO nested resources?
+public final class CurrentResourceContext {
+
+ private static final Class<CurrentResourceContext> CONTEXT_ATTRIBUTE_KEY = CurrentResourceContext.class;
+
+ private Resource resource = null;
+
+ private CurrentResourceContext() {
+ }
+
+ public static CurrentResourceContext getInstance(FacesContext facesContext) {
+ Map<Object, Object> attributes = facesContext.getAttributes();
+ CurrentResourceContext stack = (CurrentResourceContext) attributes.get(CONTEXT_ATTRIBUTE_KEY);
+ if (stack == null) {
+ stack = new CurrentResourceContext();
+ attributes.put(CONTEXT_ATTRIBUTE_KEY, stack);
+ }
+
+ return stack;
+ }
+
+ public void setResource(Resource resource) {
+ this.resource = resource;
+ }
+
+ public Resource getResource() {
+ return resource;
+ }
+}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ELContextImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ELContextImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ELContextImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -21,24 +21,43 @@
*/
package org.richfaces.cdk.faces;
+import javax.el.CompositeELResolver;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.FunctionMapper;
import javax.el.VariableMapper;
+import org.richfaces.skin.SkinPropertiesELResolver;
+
/**
* @author Nick Belaevski
*
*/
public class ELContextImpl extends ELContext {
+ private VariableMapper variableMapper = createVariableMapper();
+
+ private ELResolver elResolver = createELResolver();
+
+ private VariableMapper createVariableMapper() {
+ return new VariableMapperImpl();
+ }
+
+ private ELResolver createELResolver() {
+ CompositeELResolver result = new CompositeELResolver();
+
+ result.add(new SkinPropertiesELResolver());
+ result.add(new ResourceELResolver());
+
+ return result;
+ }
+
/* (non-Javadoc)
* @see javax.el.ELContext#getELResolver()
*/
@Override
public ELResolver getELResolver() {
- // TODO Auto-generated method stub
- return null;
+ return elResolver;
}
/* (non-Javadoc)
@@ -50,13 +69,9 @@
return null;
}
- /* (non-Javadoc)
- * @see javax.el.ELContext#getVariableMapper()
- */
@Override
public VariableMapper getVariableMapper() {
- // TODO Auto-generated method stub
- return null;
+ return variableMapper;
}
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ExternalContextImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -379,4 +379,8 @@
}
+ @Override
+ public String getResponseCharacterEncoding() {
+ return "UTF-8";
+ }
}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/FacesContextImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/FacesContextImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/FacesContextImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -43,21 +43,25 @@
private Map<Object, Object> attributes = new HashMap<Object, Object>();
- private ELContext elContext = new ELContextImpl();
+ private ELContext elContext = createELContext();
private ExternalContextImpl externalContext = new ExternalContextImpl();
+ private ApplicationImpl application = new ApplicationImpl();
+
public FacesContextImpl() {
setCurrentInstance(this);
}
- /* (non-Javadoc)
- * @see javax.faces.context.FacesContext#getApplication()
- */
+ private ELContext createELContext() {
+ ELContext result = new ELContextImpl();
+ result.putContext(FacesContext.class, this);
+ return result;
+ }
+
@Override
public Application getApplication() {
- // TODO Auto-generated method stub
- return null;
+ return application;
}
/* (non-Javadoc)
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/FacesImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/FacesImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/FacesImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -31,6 +31,7 @@
import org.richfaces.application.ServicesFactory;
import org.richfaces.application.ServicesFactoryImpl;
import org.richfaces.cdk.Faces;
+import org.richfaces.cdk.FileNameMapper;
import org.richfaces.cdk.skin.SkinFactoryImpl;
import org.richfaces.skin.SkinFactory;
@@ -42,9 +43,12 @@
private String webroot;
- public FacesImpl(String webroot) {
+ private FileNameMapper fileNameMapper;
+
+ public FacesImpl(String webroot, FileNameMapper fileNameMapper) {
super();
this.webroot = webroot;
+ this.fileNameMapper = fileNameMapper;
}
public void start() {
@@ -56,6 +60,7 @@
public void configure(ServicesFactory factory) {
serviceFactory.setInstance(SkinFactory.class, skinFactory);
serviceFactory.setInstance(InitParametersStorage.class, new InitParametersStorage());
+ serviceFactory.setInstance(FileNameMapper.class, fileNameMapper);
}
};
serviceFactory.init(Collections.singleton(module));
@@ -70,10 +75,12 @@
SkinFactoryImpl.setSkinName(skinName);
}
- public void startRequest() {
+ public FacesContext startRequest() {
FacesContextImpl facesContextImpl = new FacesContextImpl();
facesContextImpl.getExternalContext().setWebRoot(webroot);
assert FacesContext.getCurrentInstance() != null;
+
+ return facesContextImpl;
}
public void stopRequest() {
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ReadOnlyValueExpression.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -0,0 +1,79 @@
+/*
+ * 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.cdk.faces;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class ReadOnlyValueExpression extends ValueExpression {
+
+ @Override
+ public abstract Object getValue(ELContext context);
+
+ @Override
+ public void setValue(ELContext context, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isReadOnly(ELContext context) {
+ return true;
+ }
+
+ @Override
+ public Class<?> getType(ELContext context) {
+ return null;
+ }
+
+ @Override
+ public Class<?> getExpectedType() {
+ return Object.class;
+ }
+
+ @Override
+ public String getExpressionString() {
+ return null;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj == this;
+ }
+
+ @Override
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ public boolean isLiteralText() {
+ return false;
+ }
+
+ protected FacesContext getFacesContext(ELContext elContext) {
+ return (FacesContext) elContext.getContext(FacesContext.class);
+ }
+}
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceELResolver.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -0,0 +1,155 @@
+/*
+ * 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.cdk.faces;
+
+import java.beans.FeatureDescriptor;
+import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.PropertyNotFoundException;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.application.ServiceTracker;
+import org.richfaces.cdk.FileNameMapper;
+
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Lists;
+import com.sun.faces.util.Util;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ResourceELResolver extends ELResolver {
+
+ private void checkBaseAndProperty(Object base, Object property) {
+ if (base == null && property == null) {
+ throw new PropertyNotFoundException("base & property are null");
+ }
+ }
+
+ private String skipEqualPathSegments(Iterator<String> path, Iterator<String> basePath) {
+ while (path.hasNext()) {
+ String pathSeg = path.next();
+ if (basePath.hasNext()) {
+ String basePathSeg = basePath.next();
+ if (basePathSeg.equals(pathSeg)) {
+ continue;
+ }
+ }
+
+ return pathSeg;
+ }
+
+ return null;
+ }
+
+ private String relativize(String path, String basePath) {
+ Iterator<String> pathItr = Splitter.on('/').split(path).iterator();
+ Iterator<String> basePathItr = Splitter.on('/').split(basePath).iterator();
+
+ List<String> resultPathSegments = Lists.newArrayList();
+ String firstNonMatchedSegment = skipEqualPathSegments(pathItr, basePathItr);
+ while (basePathItr.hasNext()) {
+ basePathItr.next();
+ resultPathSegments.add("..");
+ }
+
+ if (firstNonMatchedSegment != null) {
+ resultPathSegments.add(firstNonMatchedSegment);
+ }
+
+ while (pathItr.hasNext()) {
+ resultPathSegments.add(pathItr.next());
+ }
+
+ return Joiner.on('/').join(resultPathSegments);
+ }
+
+ public Object getValue(ELContext context, Object base, Object property) {
+ checkBaseAndProperty(base, property);
+
+ if (base instanceof ResourceHandler) {
+ ResourceHandler handler = (ResourceHandler) base;
+ String prop = (String) property;
+ Resource resource;
+ if (!prop.contains(":")) {
+ resource = handler.createResource(prop);
+ } else {
+ String[] parts = Util.split(prop, ":");
+ if (parts.length != 2) {
+ throw new ELException(MessageFormat.format("Invalid resource format. Property {0} contains more than one colon (:)", prop));
+ }
+ resource = handler.createResource(parts[1], parts[0]);
+ }
+
+ context.setPropertyResolved(true);
+
+ if (resource != null) {
+ FileNameMapper fileNameMapper = ServiceTracker.getService(FileNameMapper.class);
+ String name = fileNameMapper.createName(resource);
+
+ FacesContext facesContext = (FacesContext) context.getContext(FacesContext.class);
+ Resource contextResource = CurrentResourceContext.getInstance(facesContext).getResource();
+ if (contextResource != null) {
+ name = relativize(name, fileNameMapper.createName(contextResource));
+ }
+
+ return name;
+ }
+ }
+ return null;
+ }
+
+ public Class<?> getType(ELContext context, Object base, Object property) {
+ checkBaseAndProperty(base, property);
+ return null;
+ }
+
+ public void setValue(ELContext context, Object base, Object property, Object value) {
+ checkBaseAndProperty(base, property);
+ }
+
+ public boolean isReadOnly(ELContext context, Object base, Object property) {
+ checkBaseAndProperty(base, property);
+
+ return true;
+ }
+
+ @Override
+ public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
+ return null;
+ }
+
+ @Override
+ public Class<?> getCommonPropertyType(ELContext context, Object base) {
+ return String.class;
+ }
+
+}
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/ResourceHandlerImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -0,0 +1,146 @@
+/*
+ * 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.cdk.faces;
+
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.net.URL;
+
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+
+import org.reflections.util.Utils;
+import org.richfaces.cdk.ResourceInfo;
+import org.richfaces.cdk.resource.URLResource;
+import org.richfaces.resource.CompiledCSSResource;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.Java2DUserResourceWrapperImpl;
+import org.richfaces.resource.UserResource;
+import org.richfaces.resource.UserResourceWrapperImpl;
+
+import com.google.common.base.Strings;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class ResourceHandlerImpl extends ResourceHandler {
+
+ @Override
+ public Resource createResource(String resourceName) {
+ return createResource(resourceName, null);
+ }
+
+ @Override
+ public Resource createResource(String resourceName, String libraryName) {
+ return createResource(resourceName, libraryName, null);
+ }
+
+ @Override
+ public Resource createResource(String resourceName, String libraryName, String contentType) {
+ Resource result = null;
+ if (Strings.isNullOrEmpty(libraryName)) {
+ try {
+ Class<?> resourceClass = Class.forName(resourceName, false, Utils.getContextClassLoader());
+ if (resourceClass.isInterface() || (resourceClass.getModifiers() & Modifier.ABSTRACT) != 0) {
+ return null;
+ }
+
+ Object resourceObject = resourceClass.newInstance();
+ if (resourceObject instanceof Java2DUserResource) {
+ result = new Java2DUserResourceWrapperImpl((Java2DUserResource) resourceObject);
+ } else if (resourceObject instanceof UserResource) {
+ result = new UserResourceWrapperImpl((UserResource) resourceObject);
+ } else {
+ result = (Resource) resourceObject;
+ }
+ } catch (ClassNotFoundException e) {
+ //TODO ignore, but add to debug logs
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ if (result == null) {
+ String resourcePath;
+
+ if (libraryName != null && libraryName.length() != 0) {
+ resourcePath = libraryName + '/' + resourceName;
+ } else {
+ resourcePath = resourceName;
+ }
+
+ URL url = Utils.getContextClassLoader().getResource(ResourceInfo.CLASSPATH_RESOURCES_LOCATION + resourcePath);
+ if (url != null) {
+ result = new URLResource(url);
+
+ if (resourceName.endsWith(".ecss")) {
+ //TODO process CSS dependencies
+ result = new CompiledCSSResource(result);
+ }
+ }
+ }
+
+ if (result != null) {
+ //TODO detect content type
+ result.setContentType(contentType);
+ result.setResourceName(resourceName);
+ result.setLibraryName(libraryName);
+ }
+
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.application.ResourceHandler#libraryExists(java.lang.String)
+ */
+ @Override
+ public boolean libraryExists(String libraryName) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void handleResourceRequest(FacesContext context) throws IOException {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isResourceRequest(FacesContext context) {
+ throw new UnsupportedOperationException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.application.ResourceHandler#getRendererTypeForResourceName(java.lang.String)
+ */
+ @Override
+ public String getRendererTypeForResourceName(String resourceName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Added: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/VariableMapperImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/VariableMapperImpl.java (rev 0)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/faces/VariableMapperImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -0,0 +1,83 @@
+/*
+ * 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.cdk.faces;
+
+import javax.el.ELContext;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.skin.SkinFactory;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class VariableMapperImpl extends VariableMapper {
+
+ private static final ValueExpression SKIN_VALUE_EXPRESSION = new ReadOnlyValueExpression() {
+
+ private static final long serialVersionUID = 3552483406787835235L;
+
+ @Override
+ public Object getValue(ELContext elContext) {
+ FacesContext facesContext = getFacesContext(elContext);
+ return SkinFactory.getInstance(facesContext).getSkin(facesContext);
+ }
+ };
+
+ private static final ValueExpression RESOURCE_VALUE_EXPRESSION = new ReadOnlyValueExpression() {
+
+ private static final long serialVersionUID = -8545250767102884398L;
+
+ @Override
+ public Object getValue(ELContext elContext) {
+ FacesContext facesContext = getFacesContext(elContext);
+ return facesContext.getApplication().getResourceHandler();
+ }
+ };
+
+
+ /* (non-Javadoc)
+ * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
+ */
+ @Override
+ public ValueExpression resolveVariable(String variable) {
+ if ("richSkin".equals(variable)) {
+ return SKIN_VALUE_EXPRESSION;
+ } else if ("resource".equals(variable)) {
+ return RESOURCE_VALUE_EXPRESSION;
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
+ */
+ @Override
+ public ValueExpression setVariable(String variable, ValueExpression expression) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -21,15 +21,36 @@
*/
package org.richfaces.cdk.naming;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.application.Resource;
+
import org.richfaces.cdk.FileNameMapper;
+import com.google.common.base.Strings;
+import com.google.common.collect.Maps;
+
/**
* @author Nick Belaevski
*
*/
public class FileNameMapperImpl implements FileNameMapper {
+ private Map<String, String> mappedPackages = Maps.newLinkedHashMap();
+
+ {
+ mappedPackages.put("^org\\.richfaces\\.renderkit\\.html\\.(images\\.)?", "org.richfaces/images/");
+ mappedPackages.put("^css/", "org/richfaces/css/");
+ }
+
private String stripContentClassifier(String mimeType) {
+ if (mimeType == null) {
+ return null;
+ }
+
int idx = mimeType.lastIndexOf('/');
if (idx < 0) {
return mimeType;
@@ -38,13 +59,40 @@
}
}
- public String createName(String mimeType, String resourceName) {
- String fileName = resourceName.toLowerCase().replace('.', '_');
- String fileExt = stripContentClassifier(mimeType);
+ private String remapName(String name) {
+ if (name == null) {
+ return name;
+ }
+
+ for (Entry<String, String> mapping : mappedPackages.entrySet()) {
+ Matcher matcher = Pattern.compile(mapping.getKey()).matcher(name);
+ if (matcher.find()) {
+ return matcher.replaceAll(mapping.getValue());
+ }
+ }
+
+ return name;
+ }
+
+ @Override
+ public String createName(Resource resource) {
+ StringBuilder result = new StringBuilder();
+
+ String libraryName = resource.getLibraryName();
+ if (!Strings.isNullOrEmpty(libraryName)) {
+ result.append(libraryName);
+ result.append('/');
+ }
+
+ result.append(resource.getResourceName());
+
+ String fileExt = stripContentClassifier(resource.getContentType());
if (fileExt != null && fileExt.length() != 0) {
- fileName += ("." + fileExt);
+ result.append('.');
+ result.append(fileExt);
}
+
+ return remapName(result.toString());
+ }
- return fileName;
- }
}
Deleted: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ClassResourceProducer.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ClassResourceProducer.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ClassResourceProducer.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -1,93 +0,0 @@
-/*
- * 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.cdk.resource;
-
-import java.lang.reflect.Modifier;
-
-import javax.faces.FacesException;
-import javax.faces.application.Resource;
-
-import org.richfaces.cdk.ResourceProducer;
-import org.richfaces.resource.Java2DUserResource;
-import org.richfaces.resource.Java2DUserResourceWrapperImpl;
-
-/**
- * @author Nick Belaevski
- *
- */
-final class ClassResourceProducer implements ResourceProducer {
-
- /**
- *
- */
- private final Class<?> from;
-
- /**
- * @param from
- * @param resourceProducerFactoryImpl TODO
- */
- ClassResourceProducer(Class<?> from) {
- this.from = from;
- }
-
- private static <T> T instantiate(Class<? extends T> clazz) {
- try {
- return clazz.newInstance();
- } catch (InstantiationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (LinkageError e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- throw new FacesException(clazz.getName());
- }
-
- private Resource createResource(Class<?> classResource) {
- if (classResource.isInterface() || (classResource.getModifiers() & Modifier.ABSTRACT) != 0) {
- return null;
- }
-
- if (Resource.class.isAssignableFrom(classResource)) {
- return instantiate(classResource.asSubclass(Resource.class));
- }
-
- if (Java2DUserResource.class.isAssignableFrom(classResource)) {
- Java2DUserResource java2dResource = instantiate(classResource.asSubclass(Java2DUserResource.class));
- Resource wrapper = new Java2DUserResourceWrapperImpl(java2dResource);
- wrapper.setResourceName(classResource.getName());
- return wrapper;
- }
-
- return null;
- }
-
- @Override
- public Resource build() {
- return createResource(from);
- }
-}
\ No newline at end of file
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ReflectionsExt.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -23,6 +23,7 @@
import static com.google.common.collect.Collections2.filter;
+import java.text.MessageFormat;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -33,6 +34,7 @@
import org.reflections.Reflections;
import org.reflections.scanners.Scanner;
import org.reflections.util.Utils;
+import org.richfaces.cdk.ResourceInfo;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
@@ -46,7 +48,8 @@
private static final Predicate<String> ECSS_RESOURCE_PREDICATE = new Predicate<String>() {
- private final Pattern PATH_PATTERN = Pattern.compile("^META-INF/resources/.+\\.ecss$");
+ private final Pattern PATH_PATTERN = Pattern.compile(MessageFormat.format("^{0}.+\\.ecss$",
+ ResourceInfo.CLASSPATH_RESOURCES_LOCATION));
@Override
public boolean apply(String input) {
Deleted: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceProducerFactoryImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceProducerFactoryImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceProducerFactoryImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -1,58 +0,0 @@
-/*
- * 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.cdk.resource;
-
-
-
-import org.richfaces.cdk.ResourceProducer;
-import org.richfaces.cdk.ResourceProducerFactory;
-
-import com.google.common.base.Function;
-
-/**
- * @author Nick Belaevski
- *
- */
-public class ResourceProducerFactoryImpl implements ResourceProducerFactory {
-
- private static Function<String, ResourceProducer> urlFunction = new Function<String, ResourceProducer>() {
- public ResourceProducer apply(String from) {
- return new URLResourceProducer(from);
- }
- };
-
- private static Function<Class<?>, ResourceProducer> classFunction = new Function<Class<?>, ResourceProducer>() {
-
- public ResourceProducer apply(final Class<?> from) {
- return new ClassResourceProducer(from);
- };
- };
-
- public Function<String, ResourceProducer> getURLResourceProducerFactory() {
- return urlFunction;
- }
-
- public Function<Class<?>, ResourceProducer> getClassResourceProducerFactory() {
- return classFunction;
- }
-
-}
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourceWriterImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -28,6 +28,7 @@
import javax.faces.application.Resource;
+import org.richfaces.application.ServiceTracker;
import org.richfaces.cdk.FileNameMapper;
import org.richfaces.cdk.ResourceWriter;
@@ -41,30 +42,24 @@
private File baseDir;
- private FileNameMapper fileNameMapper;
-
- public ResourceWriterImpl(String baseDirectoryName, FileNameMapper fileNameMapper) {
+ public ResourceWriterImpl(String baseDirectoryName) {
baseDir = new File(baseDirectoryName);
baseDir.mkdirs();
-
- this.fileNameMapper = fileNameMapper;
}
+ private FileNameMapper getFileNameMapper() {
+ return ServiceTracker.getService(FileNameMapper.class);
+ }
+
public void writeResource(String skinName, Resource resource) throws IOException {
- File skinDir = new File(baseDir, skinName);
- skinDir.mkdirs();
-
- File destDir = skinDir;
- if (resource.getLibraryName() != null && resource.getLibraryName().length() != 0) {
- destDir = new File(destDir, resource.getLibraryName());
- destDir.mkdirs();
- }
-
FileOutputStream fos = null;
InputStream is = null;
try {
is = resource.getInputStream();
- File outFile = new File(destDir, fileNameMapper.createName(resource.getContentType(), resource.getResourceName()));
+
+ File skinDir = new File(baseDir, skinName);
+ File outFile = new File(skinDir, getFileNameMapper().createName(resource));
+ outFile.getParentFile().mkdirs();
outFile.createNewFile();
fos = new FileOutputStream(outFile);
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/ResourcesScannerImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -21,8 +21,11 @@
*/
package org.richfaces.cdk.resource;
+import static com.google.common.collect.Collections2.transform;
+
import java.net.URL;
import java.util.Collection;
+import java.util.Collections;
import java.util.Set;
import org.reflections.scanners.SubTypesScanner;
@@ -33,20 +36,62 @@
import org.reflections.vfs.Vfs.Dir;
import org.reflections.vfs.Vfs.File;
import org.reflections.vfs.ZipDir;
+import org.richfaces.cdk.ResourceInfo;
import org.richfaces.cdk.ResourcesScanner;
import org.richfaces.resource.DynamicResource;
+import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterators;
import com.google.common.collect.Sets;
-
/**
* @author Nick Belaevski
*
*/
public class ResourcesScannerImpl implements ResourcesScanner {
+ private static final Function<Class<?>, ResourceInfo> CLASS_RESOURCE_FUNCTION = new Function<Class<?>, ResourceInfo>() {
+
+ @Override
+ public ResourceInfo apply(Class<?> from) {
+ return new ResourceInfo(from.getName());
+ }
+ };
+
+ private static final Function<String, ResourceInfo> RELATIVE_PATH_FUNCTION = new Function<String, ResourceInfo>() {
+
+ private String getResourceRelativePath(String path) {
+ return path.substring(ResourceInfo.CLASSPATH_RESOURCES_LOCATION.length());
+ }
+
+ private String getLibraryName(String relativePath) {
+ int idx = relativePath.lastIndexOf('/');
+ if (idx < 0) {
+ return null;
+ } else {
+ return relativePath.substring(0, idx);
+ }
+ }
+
+ private String getResourceName(String relativePath) {
+ int idx = relativePath.lastIndexOf('/');
+ if (idx < 0) {
+ return relativePath;
+ } else {
+ return relativePath.substring(idx + 1);
+ }
+ }
+
+ @Override
+ public ResourceInfo apply(String from) {
+ String relPath = getResourceRelativePath(from);
+ String libraryName = getLibraryName(relPath);
+ String resourceName = getResourceName(relPath);
+ return new ResourceInfo(resourceName, libraryName);
+ }
+ };
+
private static final Predicate<File> IS_FACES_CONFIG = new Predicate<File>() {
public boolean apply(File input) {
@@ -71,11 +116,11 @@
}
};
- private Collection<Class<?>> classResources = Sets.newHashSet();
+ private Collection<ResourceInfo> resources = Sets.newHashSet();
- private Collection<String> urlResources = Sets.newHashSet();
-
public void scan() {
+ resources.clear();
+
Collection<URL> urls = Collections2.filter(ClasspathHelper.getUrlsForCurrentClasspath(), FACES_URL);
ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().setUrls(urls);
@@ -84,24 +129,21 @@
ReflectionsExt refl = new ReflectionsExt(configurationBuilder);
- Set<Class<?>> resources = refl.getTypesAnnotatedWith(DynamicResource.class);
+ Set<Class<?>> classResources = refl.getTypesAnnotatedWith(DynamicResource.class);
- // TODO - reflections doesn't handle @Inherited correctly
- for (Class<?> resourceClass : resources) {
- classResources.add(resourceClass);
- classResources.addAll(refl.getSubTypesOf(resourceClass));
+ // TODO - reflections library doesn't handle @Inherited correctly
+ for (Class<?> resourceClass : classResources) {
+ resources.addAll(transform(Collections.singleton(resourceClass), CLASS_RESOURCE_FUNCTION));
+ resources.addAll(transform(refl.getSubTypesOf(resourceClass), CLASS_RESOURCE_FUNCTION));
}
- classResources.addAll(refl.getMarkedClasses());
- urlResources.addAll(refl.getURLResources());
+ resources.addAll(transform(refl.getMarkedClasses(), CLASS_RESOURCE_FUNCTION));
+ resources.addAll(transform(refl.getURLResources(), RELATIVE_PATH_FUNCTION));
}
- public Collection<Class<?>> getClassResources() {
- return classResources;
+ @Override
+ public Collection<ResourceInfo> getResources() {
+ return resources;
}
-
- public Collection<String> getURLResources() {
- return urlResources;
- }
-
+
}
Deleted: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/URLResourceProducer.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/URLResourceProducer.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/resource/URLResourceProducer.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -1,96 +0,0 @@
-/*
- * 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.cdk.resource;
-
-import java.net.URL;
-
-import javax.faces.application.Resource;
-
-import org.reflections.util.Utils;
-import org.richfaces.cdk.ResourceProducer;
-
-/**
- * @author Nick Belaevski
- *
- */
-final class URLResourceProducer implements ResourceProducer {
- /**
- *
- */
- private final String libraryName;
- /**
- *
- */
- private final URL url;
- /**
- *
- */
- private final String resourceName;
-
- /**
- * @param libraryName
- * @param url
- * @param resourceName
- */
- URLResourceProducer(String resPath) {
- String relPath = getResourceRelativePath(resPath);
-
- url = Utils.getContextClassLoader().getResource(resPath);
- libraryName = getLibraryName(relPath);
- resourceName = getResourceName(relPath);
- }
-
- private String getResourceRelativePath(String path) {
- return path.substring("META-INF/resources/".length());
- }
-
- private String getLibraryName(String relativePath) {
- int idx = relativePath.lastIndexOf('/');
- if (idx < 0) {
- return null;
- } else {
- return relativePath.substring(0, idx);
- }
- }
-
- private String getResourceName(String relativePath) {
- int idx = relativePath.lastIndexOf('/');
- if (idx < 0) {
- return relativePath;
- } else {
- return relativePath.substring(idx + 1);
- }
- }
-
- @Override
- public Resource build() {
- URLResource resource = new URLResource(url);
-
- resource.setContentType("text/css");
-
- resource.setLibraryName(libraryName);
- resource.setResourceName(resourceName);
-
- return resource;
- }
-}
\ No newline at end of file
Modified: root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java
===================================================================
--- root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java 2010-07-27 11:43:27 UTC (rev 18241)
+++ root/cdk-sandbox/trunk/dynamic-resources-prerenderer/src/main/java/org/richfaces/cdk/task/ResourceTaskFactoryImpl.java 2010-07-27 11:45:44 UTC (rev 18242)
@@ -31,9 +31,10 @@
import javax.faces.context.FacesContext;
import org.richfaces.cdk.Faces;
-import org.richfaces.cdk.ResourceProducer;
+import org.richfaces.cdk.ResourceInfo;
import org.richfaces.cdk.ResourceTaskFactory;
import org.richfaces.cdk.ResourceWriter;
+import org.richfaces.cdk.faces.CurrentResourceContext;
import org.richfaces.resource.StateHolderResource;
import com.google.common.collect.Lists;
@@ -50,30 +51,42 @@
private String skinName;
- private ResourceProducer resourceBuilder;
+ private ResourceInfo resourceInfo;
- ResourcesRendererCallable(String skinName, ResourceProducer resourceBuilder) {
+ ResourcesRendererCallable(String skinName, ResourceInfo resourceInfo) {
this.skinName = skinName;
- this.resourceBuilder = resourceBuilder;
+ this.resourceInfo = resourceInfo;
}
+ private Resource createResource(FacesContext facesContext, ResourceInfo resourceInfo) {
+ return facesContext.getApplication().getResourceHandler().createResource(resourceInfo.getResourceName(),
+ resourceInfo.getLibraryName());
+ }
+
public Object call() throws Exception {
try {
faces.setSkin(skinName);
- faces.startRequest();
+ FacesContext facesContext = faces.startRequest();
- Resource resource = resourceBuilder.build();
+ Resource resource = createResource(facesContext, resourceInfo);
+ if (resource == null) {
+ //TODO log null resource
+ return null;
+ }
+
+ CurrentResourceContext.getInstance(facesContext).setResource(resource);
+
if (resource instanceof StateHolderResource) {
StateHolderResource stateHolderResource = (StateHolderResource) resource;
ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput();
- stateHolderResource.writeState(FacesContext.getCurrentInstance(), dataOutput);
+ stateHolderResource.writeState(facesContext, dataOutput);
byte[] bs = dataOutput.toByteArray();
//TODO use collected data
} else if (resource instanceof StateHolder) {
StateHolder stateHolder = (StateHolder) resource;
if (!stateHolder.isTransient()) {
- Object savedData = stateHolder.saveState(FacesContext.getCurrentInstance());
+ Object savedData = stateHolder.saveState(facesContext);
//TODO use collected data
}
}
@@ -95,7 +108,7 @@
private ResourceWriter resourceWriter;
- private Collection<ResourceProducer> resources = Collections.emptySet();
+ private Collection<ResourceInfo> resources = Collections.emptySet();
private Collection<String> skins = Collections.emptySet();
@@ -105,7 +118,7 @@
this.resourceWriter = resourceWriter;
}
- public void setResources(Collection<ResourceProducer> resources) {
+ public void setResources(Collection<ResourceInfo> resources) {
this.resources = resources;
}
@@ -117,8 +130,8 @@
List<Callable<Object>> result = Lists.newArrayList();
for (String skin : skins) {
- for (ResourceProducer resource : resources) {
- result.add(new ResourcesRendererCallable(skin, resource));
+ for (ResourceInfo resourceInfo : resources) {
+ result.add(new ResourcesRendererCallable(skin, resourceInfo));
}
}
14 years, 5 months
JBoss Rich Faces SVN: r18241 - in root/core/trunk/impl/src/main/java/org/richfaces/resource: css and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
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);
14 years, 5 months
JBoss Rich Faces SVN: r18240 - root/examples/richfaces-showcase/trunk/src/main/webapp/WEB-INF.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-27 07:42:34 -0400 (Tue, 27 Jul 2010)
New Revision: 18240
Modified:
root/examples/richfaces-showcase/trunk/src/main/webapp/WEB-INF/web.xml
Log:
Restored standard skinning for richfaces-showcase
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/WEB-INF/web.xml 2010-07-26 21:02:21 UTC (rev 18239)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/WEB-INF/web.xml 2010-07-27 11:42:34 UTC (rev 18240)
@@ -11,7 +11,7 @@
</welcome-file-list>
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
- <param-value>false</param-value>
+ <param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.enableControlSkinningClasses</param-name>
14 years, 5 months
JBoss Rich Faces SVN: r18239 - root.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-07-26 17:02:21 -0400 (Mon, 26 Jul 2010)
New Revision: 18239
Modified:
root/.hgignore
Log:
ignore working dirs
Modified: root/.hgignore
===================================================================
--- root/.hgignore 2010-07-26 14:07:40 UTC (rev 18238)
+++ root/.hgignore 2010-07-26 21:02:21 UTC (rev 18239)
@@ -1,3 +1,7 @@
+# use glob syntax.
+#syntax: glob
+
+\.externalToolBuilders
\.classpath
\.project
\.settings
@@ -2,3 +6,3 @@
/target$
-bin
+/bin$
.*~
14 years, 5 months
JBoss Rich Faces SVN: r18238 - in root/tests/metamer/trunk/application: src/main/java/org/richfaces/tests/metamer/bean and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-07-26 10:07:40 -0400 (Mon, 26 Jul 2010)
New Revision: 18238
Added:
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichJQueryBean.java
root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/
root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/list.xhtml
root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/simple.xhtml
root/tests/metamer/trunk/application/src/main/webapp/resources/css/richJQuery.css
Modified:
root/tests/metamer/trunk/application/pom.xml
root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
root/tests/metamer/trunk/application/src/main/webapp/index.xhtml
root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.css
root/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml
Log:
* index page refactored
* added ui:debug to application
* added component rich:jQuery
* added dependency on ui-misc to pom.xml
Modified: root/tests/metamer/trunk/application/pom.xml
===================================================================
--- root/tests/metamer/trunk/application/pom.xml 2010-07-26 13:07:40 UTC (rev 18237)
+++ root/tests/metamer/trunk/application/pom.xml 2010-07-26 14:07:40 UTC (rev 18238)
@@ -46,26 +46,20 @@
<artifactId>richfaces-components-ui</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>annotations</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.richfaces.ui.iteration</groupId>
- <artifactId>richfaces-ui-iteration-api</artifactId>
+ <artifactId>richfaces-ui-iteration-ui</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.ui.iteration</groupId>
- <artifactId>richfaces-ui-iteration-ui</artifactId>
+ <groupId>org.richfaces.ui.output</groupId>
+ <artifactId>richfaces-ui-output-ui</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.ui.iteration</groupId>
- <artifactId>richfaces-ui-iteration-impl</artifactId>
+ <groupId>org.richfaces.ui.misc</groupId>
+ <artifactId>richfaces-ui-misc-ui</artifactId>
</dependency>
-
<dependency>
- <groupId>org.richfaces.ui.output</groupId>
- <artifactId>richfaces-ui-output-ui</artifactId>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>annotations</artifactId>
</dependency>
<!-- Java Server Faces 2 -->
Modified: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java
===================================================================
--- root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-26 13:07:40 UTC (rev 18237)
+++ root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichBean.java 2010-07-26 14:07:40 UTC (rev 18238)
@@ -108,6 +108,7 @@
components.put("richDataTable", "Rich Data Table");
components.put("richExtendedDataTable", "Rich Extended Data Table");
components.put("richFunctions", "Rich Functions");
+ components.put("richJQuery", "Rich jQuery");
components.put("richList", "Rich List");
components.put("richPanel", "Rich Panel");
}
@@ -228,6 +229,36 @@
this.components = components;
}
+ public List<String> getRichComponents() {
+ List<String> richComponents = new ArrayList<String>();
+ for (String aComponent : components.keySet()) {
+ if (aComponent.startsWith("rich")) {
+ richComponents.add(aComponent);
+ }
+ }
+ return richComponents;
+ }
+
+ public List<String> getA4JComponents() {
+ List<String> a4jComponents = new ArrayList<String>();
+ for (String aComponent : components.keySet()) {
+ if (aComponent.startsWith("a4j")) {
+ a4jComponents.add(aComponent);
+ }
+ }
+ return a4jComponents;
+ }
+
+ public List<String> getOtherComponents() {
+ List<String> otherComponents = new ArrayList<String>();
+ for (String aComponent : components.keySet()) {
+ if (!aComponent.startsWith("rich") && !aComponent.startsWith("a4j")) {
+ otherComponents.add(aComponent);
+ }
+ }
+ return otherComponents;
+ }
+
public String getContainer() {
return container;
}
Added: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichJQueryBean.java
===================================================================
--- root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichJQueryBean.java (rev 0)
+++ root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichJQueryBean.java 2010-07-26 14:07:40 UTC (rev 18238)
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * 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.tests.metamer.bean;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.annotation.PostConstruct;
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.ViewScoped;
+
+import org.richfaces.component.UIJQuery;
+import org.richfaces.tests.metamer.Attributes;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Managed bean for rich:jQuery.
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>, Nick Belaevski
+ * @version $Revision$
+ */
+@ManagedBean(name = "richJQueryBean")
+@ViewScoped
+public class RichJQueryBean implements Serializable {
+
+ private static final long serialVersionUID = 111475400649809L;
+ private static Logger logger;
+ private Attributes attributes;
+ private List<String> componentsDataList;
+
+ /**
+ * Initializes the managed bean.
+ */
+ @PostConstruct
+ public void init() {
+ logger = LoggerFactory.getLogger(getClass());
+ logger.debug("initializing bean " + getClass().getName());
+
+ componentsDataList = new ArrayList<String>();
+ addComponent();
+
+ attributes = Attributes.getUIComponentAttributes(UIJQuery.class, getClass());
+
+ attributes.setAttribute("event", "click");
+ attributes.setAttribute("name", "bubu");
+ attributes.setAttribute("query", "alert('immediate attachment')");
+ attributes.setAttribute("rendered", true);
+ attributes.setAttribute("selector", "#jQueryTestButton");
+ attributes.setAttribute("timing", "immediate");
+
+ // TODO must be tested in other way
+ attributes.remove("name");
+
+ }
+
+ public Attributes getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Attributes attributes) {
+ this.attributes = attributes;
+ }
+
+ public List<String> getComponentsDataList() {
+ return componentsDataList;
+ }
+
+ public void addComponent() {
+ componentsDataList.add(UUID.randomUUID().toString());
+ }
+}
Property changes on: root/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichJQueryBean.java
___________________________________________________________________
Name: svn:keywords
+ Revision
Added: root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/list.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/list.xhtml (rev 0)
+++ root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/list.xhtml 2010-07-26 14:07:40 UTC (rev 18238)
@@ -0,0 +1,17 @@
+<!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:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j" xmlns:c="http://java.sun.com/jsp/jstl/core">
+
+<h:head>
+ <title>Rich jQuery</title>
+ <meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
+ <h:outputStylesheet library="css" name="list.css" />
+</h:head>
+
+<h:body>
+
+ <h:link outcome="simple" value="Simple" styleClass="link"/>
+ <div class="description">Simple page that contains <b>rich:jQuery</b> and inputs for all its attributes.</div>
+
+</h:body>
+</html>
\ No newline at end of file
Added: root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/simple.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/simple.xhtml (rev 0)
+++ root/tests/metamer/trunk/application/src/main/webapp/components/richJQuery/simple.xhtml 2010-07-26 14:07:40 UTC (rev 18238)
@@ -0,0 +1,71 @@
+<!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:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:ta="http://java.sun.com/jsf/composite/testapp" xmlns:misc="http://richfaces.org/misc">
+
+ <ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="head">
+ <f:metadata>
+ <f:viewParam name="templates" value="#{templateBean.templates}">
+ <f:converter converterId="templatesListConverter" />
+ </f:viewParam>
+ </f:metadata>
+ <h:outputStylesheet library="css" name="richJQuery.css"/>
+ </ui:define>
+
+ <ui:define name="outOfTemplateBefore">
+ </ui:define>
+
+ <ui:define name="component">
+
+ <fieldset id="simpleJQueryFieldset">
+ <legend>jQuery (settings below)</legend>
+
+ <input id="jQueryTestButton" type="button" value="Click here"/>
+
+ <input id="rebindOneClickButton" type="button" onclick="rebindOneClickEvent(); return false;" value="Re-enable one-typed click handler"/>
+
+ <misc:jQuery id="jQuery"
+ attachType="#{richJQueryBean.attributes['attachType'].value}"
+ event="#{richJQueryBean.attributes['event'].value}"
+ query="#{richJQueryBean.attributes['query'].value}"
+ rendered="#{richJQueryBean.attributes['rendered'].value}"
+ selector="#{richJQueryBean.attributes['selector'].value}"
+ timing="#{richJQueryBean.attributes['timing'].value}"
+ />
+
+ <misc:jQuery id="rebindJQuery" event="click" name="rebindOneClickEvent" selector="#jQueryTestButton" query="alert('one attachType rebound event')" attachType="one" />
+ </fieldset>
+
+ <br/>
+
+ <fieldset id="dataTestingFieldset">
+ <legend>testing data</legend>
+
+ <h:panelGroup id="liveTestGroup">
+ <ui:repeat id="liveTestRepeat" value="#{richJQueryBean.componentsDataList}" var="data">
+ <h:panelGroup styleClass="liveTestComponent" layout="block" id="liveTestComponent">
+ #{data}
+ </h:panelGroup>
+ </ui:repeat>
+ </h:panelGroup>
+
+ <misc:jQuery id="liveTestJQuery" selector="#liveTestGroup .liveTestComponent" attachType="live" event="click" query="alert(jQuery(this).text())" />
+
+ <br/>
+
+ <h:commandButton id="addComponentButton" value="Add component for live test" action="#{richJQueryBean.addComponent}">
+ <a4j:ajax render=":liveTestGroup"/>
+ </h:commandButton>
+
+ </fieldset>
+
+ </ui:define>
+
+ <ui:define name="outOfTemplateAfter">
+ <ta:attributes value="#{richJQueryBean.attributes}" id="attributes" render="log"/>
+ </ui:define>
+
+ </ui:composition>
+</html>
\ No newline at end of file
Modified: root/tests/metamer/trunk/application/src/main/webapp/index.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/index.xhtml 2010-07-26 13:07:40 UTC (rev 18237)
+++ root/tests/metamer/trunk/application/src/main/webapp/index.xhtml 2010-07-26 14:07:40 UTC (rev 18238)
@@ -1,5 +1,6 @@
<!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:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<title>Metamer: RichFaces Testing Application</title>
@@ -9,13 +10,36 @@
</h:head>
<h:body>
- <h1>Metamer: RichFaces Testing Application</h1>
+ <h1>Metamer: RichFaces Testing Application</h1>
<h:form id="linksForm">
- <h:panelGrid id="attributes">
- <c:forEach items="#{richBean.components}" var="entry">
- <h:link outcome="/components/#{entry.key}/list" value="#{entry.value}" styleClass="link"/>
- </c:forEach>
+ <h:panelGrid id="components" columns="3" columnClasses="valign-top,valign-top,valign-top">
+ <h:panelGroup id="a4jComponents" layout="block" style="width: 300px;">
+ <ul>
+ <a4j:repeat value="#{richBean.a4JComponents}" var="comp">
+ <li><h:link outcome="/components/#{comp}/list" value="#{richBean.components[comp]}" styleClass="link"/></li>
+ </a4j:repeat>
+ </ul>
+ </h:panelGroup>
+
+ <h:panelGroup id="richComponents" layout="block" style="width: 300px;">
+ <ul>
+ <a4j:repeat value="#{richBean.richComponents}" var="comp">
+ <li><h:link outcome="/components/#{comp}/list" value="#{richBean.components[comp]}" styleClass="link"/></li>
+ </a4j:repeat>
+ </ul>
+ </h:panelGroup>
+
+ <h:panelGroup id="otherComponents" layout="block" style="width: 300px;">
+ <ul>
+ <a4j:repeat value="#{richBean.otherComponents}" var="comp">
+ <li><h:link outcome="/components/#{comp}/list" value="#{richBean.components[comp]}" styleClass="link"/></li>
+ </a4j:repeat>
+ </ul>
+ </h:panelGroup>
</h:panelGrid>
+
+ <hr style="width: 900px; margin-left: 0px;"/>
+ #{a4j.version}
</h:form>
</h:body>
</html>
\ No newline at end of file
Modified: root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.css
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.css 2010-07-26 13:07:40 UTC (rev 18237)
+++ root/tests/metamer/trunk/application/src/main/webapp/resources/css/common.css 2010-07-26 14:07:40 UTC (rev 18238)
@@ -22,4 +22,8 @@
a img {
border: 0px;
+}
+
+.valign-top {
+ vertical-align: top;
}
\ No newline at end of file
Added: root/tests/metamer/trunk/application/src/main/webapp/resources/css/richJQuery.css
===================================================================
Modified: root/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml
===================================================================
--- root/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml 2010-07-26 13:07:40 UTC (rev 18237)
+++ root/tests/metamer/trunk/application/src/main/webapp/templates/header.xhtml 2010-07-26 14:07:40 UTC (rev 18238)
@@ -12,18 +12,22 @@
</h:graphicImage>
</h:panelGrid>
- <h:panelGrid columns="2" width="180px">
- <h:outputLabel id="a4jLogLabel" for="a4jLogCheckbox" value="Display log" />
+ <h:panelGrid columns="2" width="230px">
+ <h:outputText id="a4jLogLabel" value="Display log" />
<h:selectBooleanCheckbox id="a4jLogCheckbox" value="#{richBean.log}">
<a4j:ajax event="change" execute="@this" render="a4jLogPanel" />
</h:selectBooleanCheckbox>
- <h:outputLabel id="a4jStatusLabel" for="a4jStatus" value="Status" />
+ <h:outputText id="a4jStatusLabel" value="Status" />
<a4j:status id="a4jStatus">
<f:facet name="start">
<h:outputText value="WORKING" style="color: red;" />
</f:facet>
</a4j:status>
+
+ <h:outputText id="showUiDebugLabel" value="Show ui:debug" />
+ <h:outputText id="showUiDebug" value="Ctrl+Shift+L" />
+ <ui:debug hotkey="L" />
</h:panelGrid>
<h:panelGrid columns="2">
14 years, 5 months
JBoss Rich Faces SVN: r18237 - in root/core/trunk/impl/src/main/java/org: richfaces/renderkit/html and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-26 09:07:40 -0400 (Mon, 26 Jul 2010)
New Revision: 18237
Added:
root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkinFactory.java
Modified:
root/core/trunk/impl/src/main/java/org/ajax4jsf/context/InitParametersStorage.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java
root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
Log:
Resources bug fixes & updates
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/context/InitParametersStorage.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/context/InitParametersStorage.java 2010-07-26 12:48:16 UTC (rev 18236)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/context/InitParametersStorage.java 2010-07-26 13:07:40 UTC (rev 18237)
@@ -39,7 +39,7 @@
return storage.get(key);
}
- public Object put(String key,Object value) {
+ public Object put(String key,Object value) {
return storage.put(key, value);
}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java 2010-07-26 12:48:16 UTC (rev 18236)
+++ root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/Base2WayGradient.java 2010-07-26 13:07:40 UTC (rev 18237)
@@ -3,17 +3,19 @@
*/
package org.richfaces.renderkit.html;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+
import org.richfaces.renderkit.html.images.GradientType;
import org.richfaces.renderkit.html.images.GradientType.BiColor;
-import java.awt.*;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-
/**
* @author asmirnov
*/
-public class Base2WayGradient extends BaseGradient {
+public abstract class Base2WayGradient extends BaseGradient {
/**
* @param horizontal
Modified: root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2010-07-26 12:48:16 UTC (rev 18236)
+++ root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2010-07-26 13:07:40 UTC (rev 18237)
@@ -71,8 +71,6 @@
this.baseColor = baseColor != null ? baseColor : Skin.HEADER_BACKGROUND_COLOR;
this.gradientColor = gradientColor != null ? gradientColor : Skin.HEADER_GRADIENT_COLOR;
this.horizontal = horizontal;
-
- initialize();
}
public BaseGradient(int width, int height, int gradientHeight) {
@@ -243,6 +241,8 @@
}
public void writeState(FacesContext context, DataOutput dataOutput) throws IOException {
+ initialize();
+
dataOutput.writeInt(this.headerBackgroundColor);
dataOutput.writeInt(this.headerGradientColor);
dataOutput.writeByte((byte) this.gradientType.ordinal());
Modified: root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java 2010-07-26 12:48:16 UTC (rev 18236)
+++ root/core/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java 2010-07-26 13:07:40 UTC (rev 18237)
@@ -64,11 +64,6 @@
public CustomizeableGradient() {
super(ImageType.PNG);
-
- String gradientTypeString = safeTrim(getValueParameter(FacesContext.getCurrentInstance(), Skin.GRADIENT_TYPE));
- if (gradientTypeString != null && gradientTypeString.length() != 0) {
- gradientType = GradientType.getByParameter(gradientTypeString);
- }
}
// @Override
@@ -189,6 +184,12 @@
dataOutput.writeInt(this.gradientColor);
dataOutput.writeInt(this.gradientHeight);
dataOutput.writeByte((byte) this.gradientAlignment.ordinal());
+
+ String gradientTypeString = safeTrim(getValueParameter(FacesContext.getCurrentInstance(), Skin.GRADIENT_TYPE));
+ if (gradientTypeString != null && gradientTypeString.length() != 0) {
+ gradientType = GradientType.getByParameter(gradientTypeString);
+ }
+
dataOutput.writeByte((byte) this.gradientType.ordinal());
}
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-26 12:48:16 UTC (rev 18236)
+++ root/core/trunk/impl/src/main/java/org/richfaces/resource/CompiledCSSResource.java 2010-07-26 13:07:40 UTC (rev 18237)
@@ -31,7 +31,6 @@
import javax.faces.application.ProjectStage;
import javax.faces.application.Resource;
-import javax.faces.application.ResourceHandler;
import javax.faces.context.FacesContext;
import org.richfaces.log.RichfacesLogger;
@@ -56,21 +55,27 @@
private static final String NULL_STYLESHEET = "Parsed stylesheet for ''{0}'':''{1}'' resource is null.";
- private ResourceHandler defaultHandler;
+ //TODO handle sourceResources headers, etc.
+ private Resource sourceResource;
- public CompiledCSSResource(String resourceName, String libraryName, ResourceHandler defaultHandler) {
- setResourceName(resourceName);
- setLibraryName(libraryName);
- this.defaultHandler = defaultHandler;
+ public CompiledCSSResource(Resource sourceResource) {
+ assert sourceResource != null;
+
+ this.sourceResource = sourceResource;
}
+ @Override
+ public String getLibraryName() {
+ return sourceResource.getLibraryName();
+ }
+
+ @Override
+ public String getResourceName() {
+ return sourceResource.getResourceName();
+ }
+
public InputStream getResourceInputStream() throws IOException {
- Resource resource = defaultHandler.createResource(getResourceName(), getLibraryName(), "text/plain");
- if (resource == null) {
- return null;
- }
-
- return resource.getInputStream();
+ return sourceResource.getInputStream();
}
@Override
@@ -92,7 +97,7 @@
// parse and create a stylesheet composition
styleSheet = parser.parseStyleSheet(source, null, null);
} catch (Exception e) {
- System.out.println(e);
+ LOGGER.error(e.getMessage(), e);
} finally {
if (stream != null) {
try {
@@ -105,7 +110,7 @@
if (styleSheet != null) {
// TODO nick - handle encoding
- String encoding = FacesContext.getCurrentInstance().getExternalContext().getResponseCharacterEncoding();
+ String encoding = ctx.getExternalContext().getResponseCharacterEncoding();
CSSVisitorImpl cssVisitor = new CSSVisitorImpl();
cssVisitor.setEncoding(encoding != null ? encoding : "UTF-8");
cssVisitor.visitStyleSheet(styleSheet);
@@ -127,7 +132,7 @@
}
private static int getSkinHashCode(FacesContext context) {
- Skin skin = SkinFactory.getInstance().getSkin(context);
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
return skin.hashCode(context);
}
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-07-26 12:48:16 UTC (rev 18236)
+++ root/core/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2010-07-26 13:07:40 UTC (rev 18237)
@@ -175,6 +175,15 @@
context.getExternalContext().setResponseStatus(HttpServletResponse.SC_NOT_FOUND);
}
+ private Resource createCompiledCSSResource(String resourceName, String libraryName) {
+ Resource sourceResource = defaultHandler.createResource(resourceName, libraryName, "text/plain");
+ if (sourceResource != null) {
+ return new CompiledCSSResource(sourceResource);
+ }
+
+ return null;
+ }
+
@Override
public void handleResourceRequest(FacesContext context) throws IOException {
if (isThisHandlerResourceRequest(context)) {
@@ -203,7 +212,7 @@
if (resourceName.lastIndexOf(".ecss") != -1) {
String libraryName = resourceCodec.decodeLibraryName(context, resourcePath);
- resource = new CompiledCSSResource(resourceName, libraryName, defaultHandler);
+ resource = createCompiledCSSResource(resourceName, libraryName);
}
if (resource == null) {
@@ -457,7 +466,7 @@
resourceName = extractParametersFromResourceName(resourceName);
if (resourceName.lastIndexOf(".ecss") != -1) {
//TODO nick - params?
- result = new CompiledCSSResource(resourceName, libraryName, defaultHandler);
+ result = createCompiledCSSResource(resourceName, libraryName);
} else {
//TODO nick - libraryName as package name?
if ((resourceName != null) && ((libraryName == null) || (libraryName.length() == 0))) {
Added: root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkinFactory.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkinFactory.java (rev 0)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/AbstractSkinFactory.java 2010-07-26 13:07:40 UTC (rev 18237)
@@ -0,0 +1,232 @@
+/*
+ * 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.skin;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.FutureTask;
+
+import javax.el.ELContext;
+import javax.el.ExpressionFactory;
+import javax.faces.application.Application;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.Messages;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
+import org.ajax4jsf.util.ELUtils;
+import org.richfaces.log.RichfacesLogger;
+import org.slf4j.Logger;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class AbstractSkinFactory extends SkinFactory {
+
+ private final class SkinBuilder implements Callable<Skin> {
+
+ private String skinName;
+
+ SkinBuilder(String skinName) {
+ super();
+ this.skinName = skinName;
+ }
+
+ public Skin call() throws Exception {
+ return buildSkin(FacesContext.getCurrentInstance(), skinName);
+ }
+
+ }
+
+ /**
+ * Resource Uri for properties file with default values of skin parameters.
+ */
+ private static final String DEFAULT_SKIN_PATH = "META-INF/skins/%s.skin.properties";
+
+ // private static final String[] DEFAULT_SKIN_PATHS = { DEFAULT_SKIN_PATH };
+ private static final String USER_SKIN_PATH = "%s.skin.properties";
+
+ /**
+ * Path in jar to pre-defined vendor and custom user-defined skins
+ * definitions. in this realisation "META-INF/skins/" for vendor , "" -
+ * user-defined.
+ */
+ private static final String[] SKINS_PATHS = {DEFAULT_SKIN_PATH, USER_SKIN_PATH};
+ private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
+
+ private ConcurrentMap<String, FutureTask<Skin>> skins = new ConcurrentHashMap<String, FutureTask<Skin>>();
+
+ protected void processProperties(FacesContext context, Map<Object, Object> properties) {
+ ELContext elContext = context.getELContext();
+
+ // replace all EL-expressions by prepared ValueBinding ?
+ Application app = context.getApplication();
+
+ for (Entry<Object, Object> entry : properties.entrySet()) {
+ Object propertyObject = entry.getValue();
+
+ if (propertyObject instanceof String) {
+ String property = (String) propertyObject;
+
+ if (ELUtils.isValueReference(property)) {
+ ExpressionFactory expressionFactory = app.getExpressionFactory();
+
+ entry.setValue(expressionFactory.createValueExpression(elContext, property, Object.class));
+ } else {
+ entry.setValue(property);
+ }
+ }
+ }
+ }
+
+ /**
+ * Factory method for build skin from properties files. for given skin name,
+ * search in classpath all resources with name 'name'.skin.properties and
+ * append in content to default properties. First, get it from
+ * META-INF/skins/ , next - from root package. for any place search order
+ * determined by {@link java.lang.ClassLoader } realisation.
+ *
+ * @param name name for builded skin.
+ * @param defaultProperties
+ * @return skin instance for current name
+ * @throws SkinNotFoundException -
+ * if no skin properies found for name.
+ */
+ protected Skin buildSkin(FacesContext context, String name) throws SkinNotFoundException {
+ Properties skinParams = loadProperties(name, SKINS_PATHS);
+ processProperties(context, skinParams);
+
+ return new SkinImpl(skinParams);
+ }
+
+ /**
+ * @param name
+ * @param paths
+ * @return
+ * @throws SkinNotFoundException
+ */
+ protected Properties loadProperties(String name, String[] paths) throws SkinNotFoundException {
+ ClassLoader loader = getClassLoader();
+
+ // Get properties for concrete skin.
+ Properties skinProperties = new Properties();
+ int loadedPropertiesCount = 0;
+
+ for (int i = 0; i < paths.length; i++) {
+ String skinPropertiesLocation = paths[i].replaceAll("%s", name);
+
+ if (loadProperties(loader, skinProperties, skinPropertiesLocation)) {
+ loadedPropertiesCount++;
+ }
+ }
+
+ if (loadedPropertiesCount == 0) {
+ throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR, name));
+ }
+
+ return skinProperties;
+ }
+
+ /**
+ * @param loader
+ * @param properties
+ * @param location
+ */
+ protected boolean loadProperties(ClassLoader loader, Properties properties, String location) {
+ boolean loaded = false;
+
+ try {
+ Enumeration<URL> resources = loader.getResources(location);
+
+ while (resources.hasMoreElements()) {
+ URL url = (URL) resources.nextElement();
+ InputStream propertyStream = null;
+
+ try {
+ propertyStream = URLToStreamHelper.urlToStream(url);
+ properties.load(propertyStream);
+ loaded = true;
+ } catch (IOException e) {
+ LOG.warn(Messages.getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
+
+ continue;
+ } finally {
+ if (null != propertyStream) {
+ propertyStream.close();
+ }
+ }
+ }
+ } catch (IOException e) {
+
+ // Do nothing - we can only log error, and continue to load next
+ // property.
+ if (LOG.isInfoEnabled()) {
+ LOG.info(Messages.getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
+ }
+ }
+
+ return loaded;
+ }
+
+ /**
+ * @return
+ */
+ protected ClassLoader getClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ @Override
+ public Skin getSkin(FacesContext context, String name) {
+ if (null == name) {
+ throw new SkinNotFoundException(Messages.getMessage(Messages.NULL_SKIN_NAME_ERROR));
+ }
+
+ FutureTask<Skin> skinFuture = skins.get(name);
+ if (skinFuture == null) {
+ FutureTask<Skin> newSkinFuture = new FutureTask<Skin>(new SkinBuilder(name));
+ skinFuture = skins.putIfAbsent(name, newSkinFuture);
+
+ if (skinFuture == null) {
+ skinFuture = newSkinFuture;
+ }
+ }
+
+ try {
+ skinFuture.run();
+ return skinFuture.get();
+ } catch (InterruptedException e) {
+ throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR), e);
+ } catch (ExecutionException e) {
+ throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR), e);
+ }
+ }
+
+}
Modified: root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2010-07-26 12:48:16 UTC (rev 18236)
+++ root/core/trunk/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2010-07-26 13:07:40 UTC (rev 18237)
@@ -21,31 +21,14 @@
package org.richfaces.skin;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Properties;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.FutureTask;
-import javax.el.ELContext;
-import javax.el.ExpressionFactory;
-import javax.faces.application.Application;
import javax.faces.context.FacesContext;
import org.ajax4jsf.Messages;
import org.ajax4jsf.context.ContextInitParameters;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.util.ELUtils;
-import org.richfaces.log.RichfacesLogger;
-import org.slf4j.Logger;
/**
* Implementation of {@link SkinFactory} with building skins from properties
@@ -53,7 +36,7 @@
*
* @author shura
*/
-public class SkinFactoryImpl extends SkinFactory {
+public class SkinFactoryImpl extends AbstractSkinFactory {
private static final String SKIN_KEY = SkinFactoryImpl.class.getName() + ":skin";
@@ -66,74 +49,12 @@
*/
private static final String DEFAULT_SKIN_NAME = "DEFAULT";
- /**
- * Resource Uri for properties file with default values of skin parameters.
- */
- private static final String DEFAULT_SKIN_PATH = "META-INF/skins/%s.skin.properties";
-
private static final String[] THEME_PATHS = {"META-INF/themes/%s.theme.properties", "%s.theme.properties"};
- // private static final String[] DEFAULT_SKIN_PATHS = { DEFAULT_SKIN_PATH };
- private static final String USER_SKIN_PATH = "%s.skin.properties";
-
- /**
- * Path in jar to pre-defined vendor and custom user-defined skins
- * definitions. in this realisation "META-INF/skins/" for vendor , "" -
- * user-defined.
- */
- private static final String[] SKINS_PATHS = {DEFAULT_SKIN_PATH, USER_SKIN_PATH};
- private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
-
// private Properties defaultSkinProperties = null;
-// private static final String[] CONFIGURATIONS_PATHS = {
-// "META-INF/skins/%s.configuration.properties",
-// "%s.configuration.properties" };
- // private static final String[] DEFAULT_CONFIGURATION_PATHS = { "META-INF/skins/DEFAULT.configuration.properties" };
- private ConcurrentMap<String, FutureTask<Skin>> skins = new ConcurrentHashMap<String, FutureTask<Skin>>();
private Map<String, Theme> themes = new HashMap<String, Theme>();
- private final class SkinBuilder implements Callable<Skin> {
-
- private String skinName;
-
- SkinBuilder(String skinName) {
- super();
- this.skinName = skinName;
- }
-
- public Skin call() throws Exception {
- return buildSkin(FacesContext.getCurrentInstance(), skinName);
- }
-
- }
-
- @Override
- public Skin getSkin(FacesContext context, String name) {
- if (null == name) {
- throw new SkinNotFoundException(Messages.getMessage(Messages.NULL_SKIN_NAME_ERROR));
- }
-
- FutureTask<Skin> skinFuture = skins.get(name);
- if (skinFuture == null) {
- FutureTask<Skin> newSkinFuture = new FutureTask<Skin>(new SkinBuilder(name));
- skinFuture = skins.putIfAbsent(name, newSkinFuture);
-
- if (skinFuture == null) {
- skinFuture = newSkinFuture;
- }
- }
-
- try {
- skinFuture.run();
- return skinFuture.get();
- } catch (InterruptedException e) {
- throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR), e);
- } catch (ExecutionException e) {
- throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR), e);
- }
- }
-
public Skin getDefaultSkin(FacesContext context) {
return getSkin(context, DEFAULT_SKIN_NAME);
}
@@ -201,125 +122,6 @@
return result;
}
- private void processProperties(FacesContext context, Map<Object, Object> properties) {
- ELContext elContext = context.getELContext();
-
- // replace all EL-expressions by prepared ValueBinding ?
- Application app = context.getApplication();
-
- for (Entry<Object, Object> entry : properties.entrySet()) {
- Object propertyObject = entry.getValue();
-
- if (propertyObject instanceof String) {
- String property = (String) propertyObject;
-
- if (ELUtils.isValueReference(property)) {
- ExpressionFactory expressionFactory = app.getExpressionFactory();
-
- entry.setValue(expressionFactory.createValueExpression(elContext, property, Object.class));
- } else {
- entry.setValue(property);
- }
- }
- }
- }
-
- /**
- * Factory method for build skin from properties files. for given skin name,
- * search in classpath all resources with name 'name'.skin.properties and
- * append in content to default properties. First, get it from
- * META-INF/skins/ , next - from root package. for any place search order
- * determined by {@link java.lang.ClassLoader } realisation.
- *
- * @param name name for builded skin.
- * @param defaultProperties
- * @return skin instance for current name
- * @throws SkinNotFoundException -
- * if no skin properies found for name.
- */
- protected Skin buildSkin(FacesContext context, String name) throws SkinNotFoundException {
- Properties skinParams = loadProperties(name, SKINS_PATHS);
- processProperties(context, skinParams);
-
- return new SkinImpl(skinParams);
- }
-
- /**
- * @param name
- * @param paths
- * @return
- * @throws SkinNotFoundException
- */
- protected Properties loadProperties(String name, String[] paths) throws SkinNotFoundException {
- ClassLoader loader = getClassLoader();
-
- // Get properties for concrete skin.
- Properties skinProperties = new Properties();
- int loadedPropertiesCount = 0;
-
- for (int i = 0; i < paths.length; i++) {
- String skinPropertiesLocation = paths[i].replaceAll("%s", name);
-
- if (loadProperties(loader, skinProperties, skinPropertiesLocation)) {
- loadedPropertiesCount++;
- }
- }
-
- if (loadedPropertiesCount == 0) {
- throw new SkinNotFoundException(Messages.getMessage(Messages.SKIN_NOT_FOUND_ERROR, name));
- }
-
- return skinProperties;
- }
-
- /**
- * @return
- */
- protected ClassLoader getClassLoader() {
- return Thread.currentThread().getContextClassLoader();
- }
-
- /**
- * @param loader
- * @param properties
- * @param location
- */
- protected boolean loadProperties(ClassLoader loader, Properties properties, String location) {
- boolean loaded = false;
-
- try {
- Enumeration<URL> resources = loader.getResources(location);
-
- while (resources.hasMoreElements()) {
- URL url = (URL) resources.nextElement();
- InputStream propertyStream = null;
-
- try {
- propertyStream = URLToStreamHelper.urlToStream(url);
- properties.load(propertyStream);
- loaded = true;
- } catch (IOException e) {
- LOG.warn(Messages.getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
-
- continue;
- } finally {
- if (null != propertyStream) {
- propertyStream.close();
- }
- }
- }
- } catch (IOException e) {
-
- // Do nothing - we can only log error, and continue to load next
- // property.
- if (LOG.isInfoEnabled()) {
- LOG.info(Messages.getMessage(Messages.SKIN_PROPERTIES_IO_ERROR), e);
- }
- }
-
- return loaded;
- }
-
@Override
public Theme getTheme(FacesContext facesContext, String name) {
Theme theme = themes.get(name);
14 years, 5 months
JBoss Rich Faces SVN: r18236 - root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/panel.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-07-26 08:48:16 -0400 (Mon, 26 Jul 2010)
New Revision: 18236
Modified:
root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/panel/lookCustomization.xhtml
Log:
https://jira.jboss.org/browse/RF-8967
* fixed class name
Modified: root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/panel/lookCustomization.xhtml
===================================================================
--- root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/panel/lookCustomization.xhtml 2010-07-26 12:40:56 UTC (rev 18235)
+++ root/examples/richfaces-showcase/trunk/src/main/webapp/richfaces/panel/lookCustomization.xhtml 2010-07-26 12:48:16 UTC (rev 18236)
@@ -8,7 +8,7 @@
<ui:composition>
<style>
-.rich-panel-header {
+.rf-panel-header {
color: #0054BD;
}
@@ -49,7 +49,7 @@
<f:facet name="header">
Panel #2. Changing Style Synchronously
</f:facet>
- In this example, we define header color using the .rich-panel-header class and all panels located on the same page
+ In this example, we define header color using the .rf-panel-header class and all panels located on the same page
inherit this color
</rich:panel>
14 years, 5 months
JBoss Rich Faces SVN: r18235 - root/examples/output-demo/trunk.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-07-26 08:40:56 -0400 (Mon, 26 Jul 2010)
New Revision: 18235
Modified:
root/examples/output-demo/trunk/pom.xml
Log:
Updated output-demo POM: renamed module from panels-demo
Modified: root/examples/output-demo/trunk/pom.xml
===================================================================
--- root/examples/output-demo/trunk/pom.xml 2010-07-26 12:17:39 UTC (rev 18234)
+++ root/examples/output-demo/trunk/pom.xml 2010-07-26 12:40:56 UTC (rev 18235)
@@ -10,10 +10,10 @@
<modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.ui.panels</groupId>
- <artifactId>panels-demo</artifactId>
+ <groupId>org.richfaces.examples</groupId>
+ <artifactId>output-demo</artifactId>
<version>4.0.0-SNAPSHOT</version>
- <name>Richfaces UI Components: panels demo</name>
+ <name>Richfaces UI Components: outputs demo</name>
<packaging>war</packaging>
<url>http://jboss.org/richfaces</url>
14 years, 5 months