JBoss Rich Faces SVN: r2066 - trunk/framework/test/src/test/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-08-05 19:48:15 -0400 (Sun, 05 Aug 2007)
New Revision: 2066
Modified:
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
Log:
- isActiveData() method added to StackingTreeModel
- unit test for StackingTreeModel updated
- active, activeRoot, activeNodes attributes introduced for UITreeNodes & UIRecursiveTreeNodes
- new attributes are used in sample application
Modified: trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2007-08-05 23:48:11 UTC (rev 2065)
+++ trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2007-08-05 23:48:15 UTC (rev 2066)
@@ -154,6 +154,32 @@
assertNull(listener.getComponent());
}
+ public void testActiveData() throws Exception {
+ final ValueBinding fileVB = application.createValueBinding("#{directory.files}");
+ StackingTreeModel localFilesModel = new StackingTreeModel("file", "file", new StackingTreeModelDataProvider() {
+ public Object getData() {
+ return fileVB.getValue(facesContext);
+ }
+
+ }) {
+ protected boolean isActiveData() {
+ Map requestMap = externalContext.getRequestMap();
+ Object object = requestMap.get("file");
+ assertNotNull(object);
+ File file = (File) object;
+ if (file.getTag() == 61) {
+ return false;
+ }
+
+ return super.isActiveData();
+ }
+ };
+ directoriesModel.removeStackingModel(filesModel);
+ directoriesModel.addStackingModel(localFilesModel);
+
+ stackingTreeModel.walk(facesContext, new StackingTreeDataModelTestVisitor3(), null, null);
+ }
+
public void testKey() throws Exception {
Key key = new Key("aaa", new Integer(10));
Key key2 = new Key("aaa", new Integer(11));
@@ -347,6 +373,8 @@
assertFalse(stackingTreeModel.isLeaf());
} else if (named instanceof File) {
assertTrue(stackingTreeModel.isLeaf());
+ } else {
+ fail();
}
counter++;
@@ -387,5 +415,31 @@
return counter;
}
}
+
+ class StackingTreeDataModelTestVisitor3 implements DataVisitor, LastElementAware {
+
+ private boolean last;
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+
+ stackingTreeModel.setRowKey(rowKey);
+ Named named = (Named) stackingTreeModel.getRowData();
+ int tag = named.getTag();
+
+ if (tag == 60) {
+ assertTrue(last);
+ }
+ assertFalse(tag == 61);
+ }
+
+ public void resetLastElement() {
+ this.last = false;
+ }
+
+ public void setLastElement() {
+ this.last = true;
+ }
+ }
}
17 years, 5 months
JBoss Rich Faces SVN: r2065 - trunk/samples/treeModelDemo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-08-05 19:48:11 -0400 (Sun, 05 Aug 2007)
New Revision: 2065
Modified:
trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
Log:
- isActiveData() method added to StackingTreeModel
- unit test for StackingTreeModel updated
- active, activeRoot, activeNodes attributes introduced for UITreeNodes & UIRecursiveTreeNodes
- new attributes are used in sample application
Modified: trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2007-08-05 23:48:07 UTC (rev 2064)
+++ trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2007-08-05 23:48:11 UTC (rev 2065)
@@ -11,7 +11,7 @@
<body>
<f:view>
<h:form>
- <tree:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}" switchType="ajax">
+ <tree:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}" switchType="client">
<model:treeNodes id="project" nodes="#{loaderBean.projects}" var="project">
<tree:treeNode>
<h:commandLink action="#{project.click}" value="Project: #{project.name}" />
@@ -66,9 +66,11 @@
</model:treeNodes>
<model:recursiveTreeNodes id="archiveEntry" var="archiveEntry"
- root="#{dir.files}" nodes="#{archiveEntry.archiveEntries}">
+ root="#{dir.files}" nodes="#{archiveEntry.archiveEntries}"
+ activeRoot="#{archiveEntry.class.simpleName == 'ArchiveFile'}"
+ activeNodes="#{archiveEntry.class.simpleName == 'ArchiveEntry'}">
- <tree:treeNode id="archiveEntryNode" rendered="#{archiveEntry.class.simpleName == 'ArchiveFile' or archiveEntry.class.simpleName == 'ArchiveEntry'}">
+ <tree:treeNode id="archiveEntryNode">
<h:commandLink action="#{archiveEntry.click}" value="Archive entry: #{archiveEntry.name}" />
</tree:treeNode>
17 years, 5 months
JBoss Rich Faces SVN: r2064 - in trunk/ui/treeModel/src/main: java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-08-05 19:48:07 -0400 (Sun, 05 Aug 2007)
New Revision: 2064
Modified:
trunk/ui/treeModel/src/main/config/component/recursiveTreeNodes.xml
trunk/ui/treeModel/src/main/config/component/treeNodes.xml
trunk/ui/treeModel/src/main/java/org/richfaces/component/UIRecursiveTreeNodes.java
trunk/ui/treeModel/src/main/java/org/richfaces/component/UITreeNodes.java
Log:
- isActiveData() method added to StackingTreeModel
- unit test for StackingTreeModel updated
- active, activeRoot, activeNodes attributes introduced for UITreeNodes & UIRecursiveTreeNodes
- new attributes are used in sample application
Modified: trunk/ui/treeModel/src/main/config/component/recursiveTreeNodes.xml
===================================================================
--- trunk/ui/treeModel/src/main/config/component/recursiveTreeNodes.xml 2007-08-04 23:19:21 UTC (rev 2063)
+++ trunk/ui/treeModel/src/main/config/component/recursiveTreeNodes.xml 2007-08-05 23:48:07 UTC (rev 2064)
@@ -54,5 +54,25 @@
<description>
</description>
</property>
+ <property hidden="true">
+ <name>activeBoth</name>
+ <classname>boolean</classname>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property exist="true">
+ <name>active</name>
+ <classname>boolean</classname>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property>
+ <name>activeRoot</name>
+ <classname>boolean</classname>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property>
+ <name>activeNodes</name>
+ <classname>boolean</classname>
+ <defaultvalue>true</defaultvalue>
+ </property>
</component>
</components>
Modified: trunk/ui/treeModel/src/main/config/component/treeNodes.xml
===================================================================
--- trunk/ui/treeModel/src/main/config/component/treeNodes.xml 2007-08-04 23:19:21 UTC (rev 2063)
+++ trunk/ui/treeModel/src/main/config/component/treeNodes.xml 2007-08-05 23:48:07 UTC (rev 2064)
@@ -48,5 +48,10 @@
<description>
</description>
</property>
+ <property>
+ <name>active</name>
+ <classname>boolean</classname>
+ <defaultvalue>true</defaultvalue>
+ </property>
</component>
</components>
Modified: trunk/ui/treeModel/src/main/java/org/richfaces/component/UIRecursiveTreeNodes.java
===================================================================
--- trunk/ui/treeModel/src/main/java/org/richfaces/component/UIRecursiveTreeNodes.java 2007-08-04 23:19:21 UTC (rev 2063)
+++ trunk/ui/treeModel/src/main/java/org/richfaces/component/UIRecursiveTreeNodes.java 2007-08-05 23:48:07 UTC (rev 2064)
@@ -8,6 +8,7 @@
import javax.faces.context.FacesContext;
import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
import org.apache.commons.collections.iterators.IteratorChain;
import org.richfaces.model.StackingTreeModel;
@@ -27,12 +28,33 @@
public abstract Object getRoot();
public abstract void setRoot(Object root);
+ public abstract boolean isActiveBoth();
+ public abstract void setActiveBoth(boolean active);
+
+ public abstract boolean isActiveRoot();
+ public abstract void setActiveRoot(boolean active);
+
+ public abstract boolean isActiveNodes();
+ public abstract void setActiveNodes(boolean active);
+
+ public boolean isActive() {
+ return isActiveBoth() && isActiveRoot();
+ }
+
+ public void setActive(boolean active) {
+ setActiveBoth(active);
+ }
+
+ public void setValueBinding(String name, ValueBinding binding) {
+ if ("active".equals(name)) {
+ super.setValueBinding("activeBoth", binding);
+ } else {
+ super.setValueBinding(name, binding);
+ }
+ }
+
public Object getData() {
- try {
- return getRoot();
- } catch (PropertyNotFoundException e) {
- return new Object[0];
- }
+ return getRoot();
}
public abstract String getVar();
@@ -44,11 +66,7 @@
StackingTreeModel recursiveModel = new StackingTreeModel(getId(), getVar(), new StackingTreeModelDataProvider() {
public Object getData() {
- try {
- return UIRecursiveTreeNodes.this.getNodes();
- } catch (PropertyNotFoundException e) {
- return new Object[0];
- }
+ return UIRecursiveTreeNodes.this.getNodes();
}
}) {
@@ -78,6 +96,10 @@
protected boolean isActive() {
return UIRecursiveTreeNodes.this.isRendered();
}
+
+ protected boolean isActiveData() {
+ return UIRecursiveTreeNodes.this.isActiveBoth() && UIRecursiveTreeNodes.this.isActiveNodes();
+ }
};
stackingModel.addStackingModel(recursiveModel);
Modified: trunk/ui/treeModel/src/main/java/org/richfaces/component/UITreeNodes.java
===================================================================
--- trunk/ui/treeModel/src/main/java/org/richfaces/component/UITreeNodes.java 2007-08-04 23:19:21 UTC (rev 2063)
+++ trunk/ui/treeModel/src/main/java/org/richfaces/component/UITreeNodes.java 2007-08-05 23:48:07 UTC (rev 2064)
@@ -24,6 +24,9 @@
public abstract String getVar();
public abstract void setVar(String var);
+ public abstract boolean isActive();
+ public abstract void setActive(boolean active);
+
protected StackingTreeModel createStackingTreeModel() {
StackingTreeModel treeModel = new StackingTreeModel(getId(), getVar(), new StackingTreeModelDataProvider() {
@@ -40,6 +43,10 @@
protected boolean isActive() {
return UITreeNodes.this.isRendered();
}
+
+ protected boolean isActiveData() {
+ return UITreeNodes.this.isActive();
+ }
};
return treeModel;
17 years, 5 months
JBoss Rich Faces SVN: r2063 - trunk/framework/test/src/test/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-08-04 19:19:21 -0400 (Sat, 04 Aug 2007)
New Revision: 2063
Modified:
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
Log:
Request variable restoration added to unit tests for StackingTreeModel
Modified: trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2007-08-04 20:14:28 UTC (rev 2062)
+++ trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2007-08-04 23:19:21 UTC (rev 2063)
@@ -38,6 +38,10 @@
private StackingTreeModel directoriesModel;
private StackingTreeModel filesModel;
+ private Object projectRequestObject;
+ private Object directoryRequestObject;
+ private Object fileRequestObject;
+
/* (non-Javadoc)
* @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
*/
@@ -95,6 +99,15 @@
directoriesModel.addStackingModel(filesModel);
projectsModel.addStackingModel(directoriesModel);
this.stackingTreeModel.addStackingModel(projectsModel);
+
+ projectRequestObject = new Object();
+ directoryRequestObject = new Object();
+ fileRequestObject = new Object();
+
+ Map requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
+ requestParameterMap.put("project", projectRequestObject);
+ requestParameterMap.put("directory", directoryRequestObject);
+ requestParameterMap.put("file", fileRequestObject);
}
/* (non-Javadoc)
@@ -106,6 +119,10 @@
this.projectsModel = null;
this.directoriesModel = null;
this.filesModel = null;
+
+ this.projectRequestObject = null;
+ this.directoryRequestObject = null;
+ this.fileRequestObject = null;
}
public void testWalk() throws Exception {
@@ -115,6 +132,11 @@
this.stackingTreeModel.setRowKey(null);
assertNull(this.stackingTreeModel.getRowData());
assertFalse(this.stackingTreeModel.isLeaf());
+
+ Map requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
+ assertSame(this.projectRequestObject, requestParameterMap.get("project"));
+ assertSame(this.directoryRequestObject, requestParameterMap.get("directory"));
+ assertSame(this.fileRequestObject, requestParameterMap.get("file"));
}
public void testComponentsListener() throws Exception {
17 years, 5 months
JBoss Rich Faces SVN: r2062 - in trunk: framework/test/src/test/java/org/richfaces/model and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-08-04 16:14:28 -0400 (Sat, 04 Aug 2007)
New Revision: 2062
Added:
trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/ArchiveEntry.java
trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/ArchiveFile.java
Modified:
trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
trunk/samples/treeModelDemo/src/main/resources/org/richfaces/model/tree-model-data.xml
trunk/samples/treeModelDemo/src/main/resources/org/richfaces/service/tree-model-rules.xml
trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
trunk/ui/treeModel/src/main/java/org/richfaces/component/UIRecursiveTreeNodes.java
trunk/ui/treeModel/src/main/java/org/richfaces/component/UITreeNodes.java
Log:
- Unit tests for StackingTreeDataModel extended
- Draft implementation of handling for nested UIRecursiveTreeNodes
- Added nested UIRecursiveTreeNodes to sample
Modified: trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2007-08-04 02:19:57 UTC (rev 2061)
+++ trunk/framework/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2007-08-04 20:14:28 UTC (rev 2062)
@@ -6,7 +6,6 @@
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -19,6 +18,8 @@
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.collections.iterators.FilterIterator;
/**
* @author Nick Belaevski mailto:nbelaevski@exadel.com created 25.07.2007
@@ -103,7 +104,7 @@
return this;
} else {
Key key = (Key) keyIterator.next();
- StackingTreeModel stackingTreeModel = this.getModelById(key.modelId);
+ StackingTreeModel stackingTreeModel = this.getInternalModelById(key.modelId);
if (entriesIterator != null && entriesIterator.hasNext()) {
StackEntry entry = (StackEntry) entriesIterator.next();
if (entry.model != stackingTreeModel || entry.modelKey != key.modelKey) {
@@ -199,7 +200,7 @@
}
StackEntry lastEntry = (StackEntry) stackEntries.getLast();
- for (Iterator iterator = lastEntry.model.getModelsIterator(); iterator.hasNext();) {
+ for (Iterator iterator = lastEntry.model.getInternalModelsIterator(); iterator.hasNext();) {
StackingTreeModel stackingTreeModel = (StackingTreeModel) iterator.next();
if (!stackingTreeModel.isEmpty()) {
@@ -237,7 +238,7 @@
new Visitor1(dataVisitor));
if (treeRange == null || treeRange.processChildren(argumentKey)) {
- Iterator iterator = this.getModelsIterator();
+ Iterator iterator = this.getInternalModelsIterator();
while (iterator.hasNext()) {
StackingTreeModel model = (StackingTreeModel) iterator.next();
@@ -258,10 +259,23 @@
}
}
+ private StackingTreeModel getInternalModelById(String id) {
+ StackingTreeModel model = getModelById(id);
+ if (model.isActive()) {
+ return model;
+ }
+
+ throw new IllegalStateException();
+ }
+
public StackingTreeModel getModelById(String id) {
return (StackingTreeModel) models.get(id);
}
+ private Iterator getInternalModelsIterator() {
+ return new FilterIterator(getModelsIterator(), ACTIVE_MODEL_PREDICATE);
+ }
+
public Iterator getModelsIterator() {
return models.values().iterator();
}
@@ -350,15 +364,11 @@
public void end(FacesContext context) throws IOException {
if (shifted) {
- if (dataVisitor instanceof LastElementAware) {
- try {
- ((LastElementAware) dataVisitor).setLastElement();
- dataVisitor.process(context, this.rowKey, argument);
- } finally {
- ((LastElementAware) dataVisitor).resetLastElement();
- }
- } else {
+ try {
+ ((LastElementAware) dataVisitor).setLastElement();
dataVisitor.process(context, this.rowKey, argument);
+ } finally {
+ ((LastElementAware) dataVisitor).resetLastElement();
}
}
}
@@ -384,11 +394,7 @@
* @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
*/
public Object getRowKey() {
- if (parent == null) {
- return rowKey;
- } else {
- return this.parent.getRowKey();
- }
+ return rowKey;
}
public void setRowKey(Object key) {
@@ -499,4 +505,21 @@
parent.componentSelected(component);
}
}
+
+ protected boolean isActive() {
+ return true;
+ }
+
+ private final static Predicate ACTIVE_MODEL_PREDICATE = new Predicate() {
+
+ public boolean evaluate(Object object) {
+ StackingTreeModel model = (StackingTreeModel) object;
+ if (model == null) {
+ return false;
+ }
+
+ return model.isActive();
+ }
+
+ };
}
Modified: trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2007-08-04 02:19:57 UTC (rev 2061)
+++ trunk/framework/test/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2007-08-04 20:14:28 UTC (rev 2062)
@@ -7,11 +7,14 @@
import java.util.LinkedHashMap;
import java.util.Map;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
import org.ajax4jsf.model.DataVisitor;
import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.model.StackingTreeModel.Key;
import org.richfaces.model.entity.Directory;
import org.richfaces.model.entity.File;
import org.richfaces.model.entity.Named;
@@ -31,32 +34,35 @@
}
private StackingTreeModel stackingTreeModel;
-
+ private StackingTreeModel projectsModel;
+ private StackingTreeModel directoriesModel;
+ private StackingTreeModel filesModel;
+
/* (non-Javadoc)
* @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
*/
public void setUp() throws Exception {
super.setUp();
this.stackingTreeModel = new StackingTreeModel();
- StackingTreeModel projectsModel = new StackingTreeModel("project", "project", new StackingTreeModelDataProvider() {
+ projectsModel = new StackingTreeModel("project", "project", new StackingTreeModelDataProvider() {
private Map data = null;
-
+
public Object getData() {
if (data == null) {
data = new LinkedHashMap();
Project projectA = new Project("projectA", 10);
-
+
Directory adir1 = new Directory("ADir1", 50);
-
+
adir1.addFile(new File("AFile1", 60));
adir1.addFile(new File("AFile2", 61));
-
+
Directory adir2 = new Directory("ADir2", 101);
projectA.addDirectory(adir1);
projectA.addDirectory(adir2);
-
+
data.put(projectA.getName(), projectA);
Project projectB = new Project("projectB", 501);
@@ -68,28 +74,24 @@
projectB.addDirectory(bdir1);
projectB.addDirectory(bdir2);
projectB.addDirectory(bdir3);
-
+
data.put(projectB.getName(), projectB);
}
return data;
}
-
});
-
final ValueBinding dirVB = application.createValueBinding("#{project.directories}");
- StackingTreeModel directoriesModel = new StackingTreeModel("directory", "directory", new StackingTreeModelDataProvider() {
+ directoriesModel = new StackingTreeModel("directory", "directory", new StackingTreeModelDataProvider() {
public Object getData() {
return dirVB.getValue(facesContext);
}
});
-
final ValueBinding fileVB = application.createValueBinding("#{directory.files}");
- StackingTreeModel filesModel = new StackingTreeModel("file", "file", new StackingTreeModelDataProvider() {
+ filesModel = new StackingTreeModel("file", "file", new StackingTreeModelDataProvider() {
public Object getData() {
return fileVB.getValue(facesContext);
}
});
-
directoriesModel.addStackingModel(filesModel);
projectsModel.addStackingModel(directoriesModel);
this.stackingTreeModel.addStackingModel(projectsModel);
@@ -101,41 +103,218 @@
public void tearDown() throws Exception {
super.tearDown();
this.stackingTreeModel = null;
+ this.projectsModel = null;
+ this.directoriesModel = null;
+ this.filesModel = null;
}
-
+
public void testWalk() throws Exception {
StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
this.stackingTreeModel.walk(facesContext, visitor1, null, null);
assertEquals(9, visitor1.getCounter());
+ this.stackingTreeModel.setRowKey(null);
+ assertNull(this.stackingTreeModel.getRowData());
+ assertFalse(this.stackingTreeModel.isLeaf());
}
+ public void testComponentsListener() throws Exception {
+ UIOutput output = new UIOutput();
+ TreeComponentModelListenerImpl listener = new TreeComponentModelListenerImpl();
+ stackingTreeModel.addTreeComponentModelListener(listener);
+ assertNull(listener.getComponent());
+ filesModel.componentSelected(output);
+ assertSame(output, listener.getComponent());
+
+ listener.reset();
+ assertNull(listener.getComponent());
+ stackingTreeModel.removeTreeComponentModelListener(listener);
+ filesModel.componentSelected(output);
+ assertNull(listener.getComponent());
+ }
+
+ public void testKey() throws Exception {
+ Key key = new Key("aaa", new Integer(10));
+ Key key2 = new Key("aaa", new Integer(11));
+ Key key3 = new Key("aaa", new Integer(10));
+ Key key4 = new Key("bbb", new Integer(10));
+
+ assertFalse(key.equals(new Key("aaa", new Integer(0)) {} ));
+
+ assertTrue(key.equals(key3));
+ assertTrue(key3.equals(key));
+ assertTrue(key2.equals(key2));
+ assertTrue(key4.equals(key4));
+
+ assertTrue(key.hashCode() == key3.hashCode());
+ assertTrue(key3.hashCode() == key.hashCode());
+ assertTrue(key2.hashCode() == key2.hashCode());
+ assertTrue(key4.hashCode() == key4.hashCode());
+
+ assertFalse(key.equals(key2));
+ assertFalse(key3.equals(key2));
+ assertFalse(key2.equals(key));
+ assertFalse(key2.equals(key3));
+
+ assertFalse(key.hashCode() == key2.hashCode());
+ assertFalse(key3.hashCode() == key2.hashCode());
+ assertFalse(key2.hashCode() == key.hashCode());
+ assertFalse(key2.hashCode() == key3.hashCode());
+
+ assertFalse(key4.equals(key));
+ assertFalse(key4.equals(key2));
+ assertFalse(key4.equals(key3));
+
+ assertFalse(key4.hashCode() == key.hashCode());
+ assertFalse(key4.hashCode() == key2.hashCode());
+ assertFalse(key4.hashCode() == key3.hashCode());
+
+ assertFalse(key.equals(key4));
+ assertFalse(key2.equals(key4));
+ assertFalse(key3.equals(key4));
+
+ assertFalse(new Key("aaa", new Integer(10)).equals(null));
+ assertFalse(new Key("aaa", null).equals(null));
+ assertFalse(new Key(null, new Integer(10)).equals(null));
+ assertFalse(new Key(null, null).equals(null));
+
+ assertFalse(key.hashCode() == key4.hashCode());
+ assertFalse(key2.hashCode() == key4.hashCode());
+ assertFalse(key3.hashCode() == key4.hashCode());
+
+ assertFalse(key.hashCode() == 0);
+ assertFalse(key2.hashCode() == 0);
+ assertFalse(key3.hashCode() == 0);
+ assertFalse(key4.hashCode() == 0);
+
+ assertTrue(new Key(null, new Integer(11)).equals(new Key(null, new Integer(11))));
+ assertFalse(new Key(null, new Integer(10)).equals(new Key(null, new Integer(11))));
+ assertFalse(new Key(null, new Integer(10)).equals(new Key("aaa", new Integer(10))));
+
+ assertTrue(new Key(null, new Integer(11)).hashCode() == new Key(null, new Integer(11)).hashCode());
+ assertFalse(new Key(null, new Integer(10)).hashCode() == new Key(null, new Integer(11)).hashCode());
+ assertFalse(new Key(null, new Integer(10)).hashCode() == new Key("aaa", new Integer(10)).hashCode());
+
+ assertTrue(new Key("aaa", null).equals(new Key("aaa", null)));
+ assertFalse(new Key("aaa", null).equals(new Key("bbb", null)));
+ assertFalse(new Key("aaa", null).equals(new Key("aaa", new Integer(10))));
+
+ assertTrue(new Key("aaa", null).hashCode() == new Key("aaa", null).hashCode());
+ assertFalse(new Key("aaa", null).hashCode() == new Key("bbb", null).hashCode());
+ assertFalse(new Key("aaa", null).hashCode() == new Key("aaa", new Integer(10)).hashCode());
+ }
+
+ class TreeComponentModelListenerImpl implements TreeComponentModelListener {
+
+ private UIComponent component;
+
+ public void componentSelected(UIComponent component) {
+ this.component = component;
+ }
+
+ public UIComponent getComponent() {
+ return component;
+ }
+
+ public void reset() {
+ this.component = null;
+ }
+ };
+
class StackingTreeDataModelTestVisitor1 implements DataVisitor, LastElementAware {
private boolean last;
private int tag = 0;
private int counter = 0;
-
+
public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
+ throws IOException {
+ StackingTreeDataModelTestVisitor2 visitor2 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor2, null, new ListRowKey(new StackingTreeModel.Key("project", "projectA")),
+ argument, false);
+
+ assertEquals(5, visitor2.getCounter());
+
+ StackingTreeDataModelTestVisitor2 visitor20 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor20, new TreeRange() {
+
+ public boolean processChildren(TreeRowKey rowKey) {
+ return false;
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return false;
+ }
+
+ }, new ListRowKey(new StackingTreeModel.Key("project", "projectA")),
+ argument, false);
+
+ assertEquals(0, visitor20.getCounter());
+
+ StackingTreeDataModelTestVisitor2 visitor21 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor21, new TreeRange() {
+
+ public boolean processChildren(TreeRowKey rowKey) {
+ return false;
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return true;
+ }
+
+ }, new ListRowKey(new StackingTreeModel.Key("project", "projectA")),
+ argument, false);
+
+ assertEquals(1, visitor21.getCounter());
+
+ StackingTreeDataModelTestVisitor2 visitor22 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor22, null, new ListRowKey(new StackingTreeModel.Key("project", "projectB")),
+ argument, false);
+
+ assertEquals(4, visitor22.getCounter());
+
+ StackingTreeDataModelTestVisitor2 visitor23 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor23, new TreeRange() {
+
+ private boolean rootProcessed = false;
+
+ public boolean processChildren(TreeRowKey rowKey) {
+ boolean result = rootProcessed;
+ rootProcessed = true;
+ return !result;
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return true;
+ }
+
+ }, new ListRowKey(new StackingTreeModel.Key("project", "projectB")),
+ argument, false);
+
+ assertEquals(4, visitor23.getCounter());
+
stackingTreeModel.setRowKey(rowKey);
+
+ assertSame(rowKey, stackingTreeModel.getRowKey());
+
assertNull(stackingTreeModel.getTreeNode());
Object rowData = stackingTreeModel.getRowData();
assertNotNull(rowData);
assertTrue(rowData instanceof Named);
-
+
Named named = (Named) rowData;
-
- if (tag == 0) {
- tag = named.getTag();
- } else {
- int currentTag = named.getTag();
- assertTrue(currentTag > tag);
- this.tag = currentTag;
- }
-
+
+ int currentTag = named.getTag();
+ assertTrue(currentTag > tag);
+ this.tag = currentTag;
+
assertFalse(this.tag % 10 == 1 ^ last);
-
+
if (named instanceof Directory) {
if ("ADir1".equals(named.getName())) {
assertFalse(stackingTreeModel.isLeaf());
@@ -147,7 +326,7 @@
} else if (named instanceof File) {
assertTrue(stackingTreeModel.isLeaf());
}
-
+
counter++;
}
@@ -158,10 +337,33 @@
public void setLastElement() {
this.last = true;
}
-
+
public int getCounter() {
return counter;
}
}
+
+ class StackingTreeDataModelTestVisitor2 implements DataVisitor {
+ private int counter = 0;
+ private int tag = 0;
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+
+ stackingTreeModel.setRowKey(rowKey);
+ Object rowData = stackingTreeModel.getRowData();
+ assertNotNull(rowData);
+ Named named = (Named) rowData;
+
+ int currentTag = named.getTag();
+ assertTrue(currentTag > tag);
+ tag = currentTag;
+ counter++;
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+ }
}
Added: trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/ArchiveEntry.java
===================================================================
--- trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/ArchiveEntry.java (rev 0)
+++ trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/ArchiveEntry.java 2007-08-04 20:14:28 UTC (rev 2062)
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 04.08.2007
+ *
+ */
+public class ArchiveEntry extends Entry {
+ private List archiveEntries = new ArrayList();
+
+ public void addArchiveEntry(ArchiveEntry entry) {
+ this.archiveEntries.add(entry);
+ }
+
+ public List getArchiveEntries() {
+ return archiveEntries;
+ }
+}
Added: trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/ArchiveFile.java
===================================================================
--- trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/ArchiveFile.java (rev 0)
+++ trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/ArchiveFile.java 2007-08-04 20:14:28 UTC (rev 2062)
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 04.08.2007
+ *
+ */
+public class ArchiveFile extends File {
+ private List archiveEntries = new ArrayList();
+
+ public void addArchiveEntry(ArchiveEntry entry) {
+ this.archiveEntries.add(entry);
+ }
+
+ public List getArchiveEntries() {
+ return archiveEntries;
+ }
+}
Modified: trunk/samples/treeModelDemo/src/main/resources/org/richfaces/model/tree-model-data.xml
===================================================================
--- trunk/samples/treeModelDemo/src/main/resources/org/richfaces/model/tree-model-data.xml 2007-08-04 02:19:57 UTC (rev 2061)
+++ trunk/samples/treeModelDemo/src/main/resources/org/richfaces/model/tree-model-data.xml 2007-08-04 20:14:28 UTC (rev 2062)
@@ -77,7 +77,18 @@
<file name="TEST-ComponentTest.xml" />
</directory>
<file name="richfaces-3.1.0-snapshot" />
- <file name="richfaces-3.1.0-sources" />
+ <archive name="richfaces-3.1.0-sources">
+ <archiveEntry name="org">
+ <archiveEntry name="richfaces">
+ <archiveEntry name="component">
+ <archiveEntry name="UITree" />
+ <archiveEntry name="UITreeNode" />
+ <archiveEntry name="UICalendar" />
+ <archiveEntry name="UIRangedNumberInput" />
+ </archiveEntry>
+ </archiveEntry>
+ </archiveEntry>
+ </archive>
<file name="richfaces-3.1.0-javadoc" />
</directory>
</project>
Modified: trunk/samples/treeModelDemo/src/main/resources/org/richfaces/service/tree-model-rules.xml
===================================================================
--- trunk/samples/treeModelDemo/src/main/resources/org/richfaces/service/tree-model-rules.xml 2007-08-04 02:19:57 UTC (rev 2061)
+++ trunk/samples/treeModelDemo/src/main/resources/org/richfaces/service/tree-model-rules.xml 2007-08-04 20:14:28 UTC (rev 2062)
@@ -36,6 +36,22 @@
</set-properties-rule>
</pattern>
+ <pattern value="*/archive">
+ <object-create-rule classname="org.richfaces.model.ArchiveFile" />
+ <set-next-rule methodname="addFile" />
+ <set-properties-rule>
+ <alias attr-name="name" prop-name="name" />
+ </set-properties-rule>
+ </pattern>
+
+ <pattern value="*/archiveEntry">
+ <object-create-rule classname="org.richfaces.model.ArchiveEntry" />
+ <set-next-rule methodname="addArchiveEntry" />
+ <set-properties-rule>
+ <alias attr-name="name" prop-name="name" />
+ </set-properties-rule>
+ </pattern>
+
<pattern value="*/package">
<object-create-rule classname="org.richfaces.model.Package" />
<set-next-rule methodname="addPackage" />
Modified: trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2007-08-04 02:19:57 UTC (rev 2061)
+++ trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2007-08-04 20:14:28 UTC (rev 2062)
@@ -64,6 +64,16 @@
<h:commandLink action="#{file.click}" value="File1: #{file.name}" />
</tree:treeNode>
</model:treeNodes>
+
+ <model:recursiveTreeNodes id="archiveEntry" var="archiveEntry"
+ root="#{dir.files}" nodes="#{archiveEntry.archiveEntries}">
+
+ <tree:treeNode id="archiveEntryNode" rendered="#{archiveEntry.class.simpleName == 'ArchiveFile' or archiveEntry.class.simpleName == 'ArchiveEntry'}">
+ <h:commandLink action="#{archiveEntry.click}" value="Archive entry: #{archiveEntry.name}" />
+ </tree:treeNode>
+
+ </model:recursiveTreeNodes>
+
</model:recursiveTreeNodes>
<%--model:treeNodes var="file" nodes="#{proj.dir.files}">
Modified: trunk/ui/treeModel/src/main/java/org/richfaces/component/UIRecursiveTreeNodes.java
===================================================================
--- trunk/ui/treeModel/src/main/java/org/richfaces/component/UIRecursiveTreeNodes.java 2007-08-04 02:19:57 UTC (rev 2061)
+++ trunk/ui/treeModel/src/main/java/org/richfaces/component/UIRecursiveTreeNodes.java 2007-08-04 20:14:28 UTC (rev 2062)
@@ -7,6 +7,7 @@
import java.util.Iterator;
import javax.faces.context.FacesContext;
+import javax.faces.el.PropertyNotFoundException;
import org.apache.commons.collections.iterators.IteratorChain;
import org.richfaces.model.StackingTreeModel;
@@ -27,8 +28,12 @@
public abstract void setRoot(Object root);
public Object getData() {
- return getRoot();
- }
+ try {
+ return getRoot();
+ } catch (PropertyNotFoundException e) {
+ return new Object[0];
+ }
+ }
public abstract String getVar();
public abstract void setVar(String var);
@@ -39,7 +44,11 @@
StackingTreeModel recursiveModel = new StackingTreeModel(getId(), getVar(), new StackingTreeModelDataProvider() {
public Object getData() {
- return UIRecursiveTreeNodes.this.getNodes();
+ try {
+ return UIRecursiveTreeNodes.this.getNodes();
+ } catch (PropertyNotFoundException e) {
+ return new Object[0];
+ }
}
}) {
@@ -65,6 +74,10 @@
return chain;
}
+
+ protected boolean isActive() {
+ return UIRecursiveTreeNodes.this.isRendered();
+ }
};
stackingModel.addStackingModel(recursiveModel);
Modified: trunk/ui/treeModel/src/main/java/org/richfaces/component/UITreeNodes.java
===================================================================
--- trunk/ui/treeModel/src/main/java/org/richfaces/component/UITreeNodes.java 2007-08-04 02:19:57 UTC (rev 2061)
+++ trunk/ui/treeModel/src/main/java/org/richfaces/component/UITreeNodes.java 2007-08-04 20:14:28 UTC (rev 2062)
@@ -36,6 +36,10 @@
super.setupModel(object, facesContext);
componentSelected(UITreeNodes.this);
}
+
+ protected boolean isActive() {
+ return UITreeNodes.this.isRendered();
+ }
};
return treeModel;
17 years, 5 months
JBoss Rich Faces SVN: r2061 - in trunk/samples: richfaces-demo/src/main/webapp/richfaces/dataTable and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: SergeySmirnov
Date: 2007-08-03 22:19:57 -0400 (Fri, 03 Aug 2007)
New Revision: 2061
Modified:
trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/common/components.properties
trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/usage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/region/usage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/script/usage.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/style/usage.xhtml
trunk/samples/virtualEarth-sample/
Log:
Modified: trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/common/components.properties
===================================================================
--- trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/common/components.properties 2007-08-04 01:05:53 UTC (rev 2060)
+++ trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/common/components.properties 2007-08-04 02:19:57 UTC (rev 2061)
@@ -46,9 +46,9 @@
ajaxListener= ajaxSupport, Ajax Listener, /images/ico_common.gif, /images/cn_ajaxListener.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/ajaxListener.jsf
region= ajaxSupport, Ajax Region, /images/ico_common.gif, /images/cn_ajaxRegion.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/region.jsf
loadBundle= ajaxResources, Bundle, /images/ico_common.gif, /images/cn_Bundle.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/bundle.jsf
-loadScript= ajaxResources, Script, /images/ico_common.gif, /images/cn_common.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/panel.jsf
-loadStyle= ajaxResources, Style, /images/ico_common.gif, /images/cn_common.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/panel.jsf
-keepAlive= ajaxResources, Keep Alive, /images/ico_common.gif, /images/cn_keepAlive.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/keepAlive.jsf
+loadScript= ajaxResources, Script, /images/ico_common.gif, /images/cn_Script.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/script.jsf
+loadStyle= ajaxResources, Style, /images/ico_common.gif, /images/cn_Style.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/style.jsf
+keepAlive= ajaxResources, Keep Alive, /images/ico_common.gif, /images/cn_KeepAlive.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/keepAlive.jsf
include= ajaxOutput, Include, /images/ico_common.gif, /images/cn_common.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/panel.jsf
mediaOutput= ajaxOutput, Media Output, /images/ico_common.gif, /images/cn_common.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/panel.jsf
outputPanel= ajaxOutput, Output Panel, /images/ico_common.gif, /images/cn_common.gif, http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., http://labs.jboss.com/file-access/default/members/jbossrichfaces/freezone..., /richfaces/panel.jsf
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/usage.xhtml 2007-08-04 01:05:53 UTC (rev 2060)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/dataTable/usage.xhtml 2007-08-04 02:19:57 UTC (rev 2061)
@@ -7,7 +7,7 @@
xmlns:rich="http://richfaces.ajax4jsf.org/rich">
<ui:composition template="/templates/component-sample.xhtml">
<ui:define name="sample">
-
+
<p>DataTable allows to show a tabular data. Additional to the stadard <h:dataTable>, this component
@@ -16,6 +16,7 @@
of a master table and detail sub-tables.<br />
The folowing example shows the dataTable component in use:
</p>
+
<div class="sample-container" >
<rich:dataTable
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/region/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/region/usage.xhtml 2007-08-04 01:05:53 UTC (rev 2060)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/region/usage.xhtml 2007-08-04 02:19:57 UTC (rev 2061)
@@ -13,7 +13,7 @@
background-color:#{a4jSkin.trimColor};
}
</style>
-
+
<p>
Ajax region is a key ajax component. It limits the part of the component tree to be processed on the server side when
ajax request comes. Processing means invocation during Decode, Validation and Model Update phase.
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/script/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/script/usage.xhtml 2007-08-04 01:05:53 UTC (rev 2060)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/script/usage.xhtml 2007-08-04 02:19:57 UTC (rev 2061)
@@ -8,10 +8,80 @@
<ui:composition template="/templates/component-sample.xhtml">
<ui:define name="sample">
+ <p>a4j:loadScript is similar to the standard script tag with src attribute, but allows
+ to load script from alternative sources like jar file.
+ </p>
<p>
+ <b>src</b> attribute defines the context relative path to the script. Instead of html
+ script tag you do not have to have a prefix to your application. The leading slash in
+ the path means the root of the web context.
</p>
-
- <div class="sample-container" >
+ <p>
+ You can use "resource://" prefix to access to the script file using
+ RichFaces resource framework. For example, if you script file is located inside the
+ jar file and has a full path there: /org/mycompany/assets/script/focus.js , you can
+ point to it with:
+ <pre>
+ <a4j:loadScript src="resource:///org/mycompany/assets/script/focus.js" />
+ </pre>
+ </p>
+ <p>
+ It is possible to register aliases to the static script files or dynamically
+ generated scripts and use those aliases then. For example, RichFaces has an
+ alias to the prototype.js script. So, you can point to "resource://prototype.js" as
+ a src for loading script and use prototype's features. The following example
+ shows how to use shipped with RichFaces prototype.js and script.aculo.us to create
+ a client-side effects.
+ </p>
+
+ <a4j:loadScript src="resource://org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/scriptaculous.js"/>
+ <a4j:loadScript src="resource:///org/richfaces/renderkit/html/scripts/scriptaculous-js-1.6.5/src/effects.js"/>
+
+ <div id="itme" class="sample-container">
+ <h:commandButton onclick="new Effect.BlindUp($('mypanel_body'), {duration:.3});return false" value="Hide"></h:commandButton>
+ <h:commandButton onclick="new Effect.Appear($('mypanel_body'));return false" value="Show"></h:commandButton>
+
+ <rich:separator height="1" style="padding:10px 0" />
+
+ <div id="mdiv">
+ <rich:panel id="mypanel">
+ <f:facet name="header">
+ <h:outputText value="Applying Skin on non-RichFaces Components"/>
+ </f:facet>
+
+
+
+
+ <h:panelGrid styleClass="rsPanel" width="250" columns="2">
+ <h:outputText styleClass="rsLabel" value="Name:" />
+ <h:inputText styleClass="rsInput" value="#{userBean.name}" />
+
+ <h:outputText styleClass="rsLabel" value="Job:" />
+ <h:inputText styleClass="rsInput" value="#{userBean.job}" />
+
+ <h:panelGroup />
+ <h:commandButton styleClass="rsButton" value="Submit">
+ <a4j:support disableDefault="true" event="onclick" reRender="out" />
+ </h:commandButton>
+
+ <f:facet name="footer">
+ </f:facet>
+
+ </h:panelGrid>
+ <h:panelGrid id="out" columns="1">
+
+ <h:outputText value=""/>
+ <h:outputText value="You have just entered:"/>
+ <h:outputText value="Name: #{userBean.name}" />
+ <h:outputText value="Job: #{userBean.job}" />
+ </h:panelGrid>
+
+ </rich:panel>
+
+ <rich:spacer height="20" />
+ </div>
+
+
</div>
</ui:define>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/style/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/style/usage.xhtml 2007-08-04 01:05:53 UTC (rev 2060)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/style/usage.xhtml 2007-08-04 02:19:57 UTC (rev 2061)
@@ -8,12 +8,84 @@
<ui:composition template="/templates/component-sample.xhtml">
<ui:define name="sample">
+ <p>a4j:loadStyle is similar to the standard style tag with src attribute, but allows
+ to load style sheet file from alternative sources like jar file.
+ </p>
<p>
+ <b>src</b> attribute defines the context relative path to the style sheet file. Instead of html
+ style tag you do not have to have a prefix to your application. The leading slash in
+ the path means the root of the web context.
</p>
+ <p>
+ You can use "resource://" prefix to access to the file using
+ RichFaces resource framework. For example, if you css file is located inside the
+ jar file and has a full path there: /org/mycompany/assets/css/common.css , you can
+ point to it with:
+ <pre>
+ <a4j:loadScript src="resource:///org/mycompany/assets/css/common.css" />
+ </pre>
+ </p>
+ <p>
+ Richfaces allows to have a dynamically generated css file based on RichFaces
+ skinability feature. xcss is a XML formated css with some additional extentions.
+ The following example shows how the look-n-feel of non-RichFaces components might
+ be changed based on the selected skin.
+ </p>
+ <a4j:loadStyle src="resource:///org/richfaces/demo/ajaxSamples/rspanel.xcss" />
+
+
+
+
<div class="sample-container" >
+ <h:form>
+
+ <rich:panel>
+ <f:facet name="header">
+ <h:outputText value="Applying Skin on non-RichFaces Components"/>
+ </f:facet>
+ <h:commandLink value="DeepMarine">
+ <a4j:actionparam name="skin" value="deepMarine" assignTo="#{skinBean.skin}"/>
+ </h:commandLink>
+ <rich:spacer width="20" />
+ <h:commandLink value="BlueSky" >
+ <a4j:actionparam name="skin" value="blueSky" assignTo="#{skinBean.skin}"/>
+ </h:commandLink>
+ <rich:spacer width="20" />
+ <h:commandLink value="JapanCherry" >
+ <a4j:actionparam name="skin" value="japanCherry" assignTo="#{skinBean.skin}"/>
+ </h:commandLink>
+
+ <rich:separator height="2" style="padding:10px 0" />
+
+ <h:panelGrid styleClass="rsPanel" width="250" columns="2">
+ <h:outputText styleClass="rsLabel" value="Name:" />
+ <h:inputText styleClass="rsInput" value="#{userBean.name}" />
+
+ <h:outputText styleClass="rsLabel" value="Job:" />
+ <h:inputText styleClass="rsInput" value="#{userBean.job}" />
+
+ <h:panelGroup />
+ <h:commandButton styleClass="rsButton" value="Submit">
+ <a4j:support disableDefault="true" event="onclick" reRender="out" />
+ </h:commandButton>
+
+ <f:facet name="footer">
+ </f:facet>
+
+ </h:panelGrid>
+ <h:panelGrid id="out" columns="1">
+
+ <h:outputText value=""/>
+ <h:outputText value="You have just entered:"/>
+ <h:outputText value="Name: #{userBean.name}" />
+ <h:outputText value="Job: #{userBean.job}" />
+ </h:panelGrid>
+
+ </rich:panel>
+ </h:form>
+
</div>
-
</ui:define>
<ui:define name="sources">
Here is a fragment of page sources for the given example:
Property changes on: trunk/samples/virtualEarth-sample
___________________________________________________________________
Name: svn:ignore
+ target
17 years, 5 months
JBoss Rich Faces SVN: r2060 - in trunk: framework/impl/src/main/java/org/ajax4jsf/application and 35 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2007-08-03 21:05:53 -0400 (Fri, 03 Aug 2007)
New Revision: 2060
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheContext.java
trunk/framework/impl/src/main/resources/META-INF/.faces-config.xml.jsfdia
trunk/ui/dataFilterSlider/src/main/java/META-INF/
trunk/ui/dataFilterSlider/src/main/java/META-INF/MANIFEST.MF
trunk/ui/dataTable/src/main/java/META-INF/
trunk/ui/dataTable/src/main/java/META-INF/MANIFEST.MF
trunk/ui/datascroller/src/main/java/META-INF/
trunk/ui/datascroller/src/main/java/META-INF/MANIFEST.MF
trunk/ui/drag-drop/src/main/java/META-INF/
trunk/ui/drag-drop/src/main/java/META-INF/MANIFEST.MF
trunk/ui/dropdown-menu/src/main/java/META-INF/
trunk/ui/dropdown-menu/src/main/java/META-INF/MANIFEST.MF
trunk/ui/gmap/src/main/java/META-INF/
trunk/ui/gmap/src/main/java/META-INF/MANIFEST.MF
trunk/ui/menu-components/src/main/java/META-INF/
trunk/ui/menu-components/src/main/java/META-INF/MANIFEST.MF
trunk/ui/modal-panel/src/main/java/META-INF/
trunk/ui/modal-panel/src/main/java/META-INF/MANIFEST.MF
trunk/ui/panel/src/main/java/META-INF/
trunk/ui/panel/src/main/java/META-INF/MANIFEST.MF
trunk/ui/panelbar/src/main/java/META-INF/
trunk/ui/panelbar/src/main/java/META-INF/MANIFEST.MF
trunk/ui/simpleTogglePanel/src/main/java/META-INF/
trunk/ui/simpleTogglePanel/src/main/java/META-INF/MANIFEST.MF
trunk/ui/spacer/src/main/java/META-INF/
trunk/ui/spacer/src/main/java/META-INF/MANIFEST.MF
trunk/ui/suggestionbox/src/main/java/META-INF/
trunk/ui/suggestionbox/src/main/java/META-INF/MANIFEST.MF
trunk/ui/togglePanel/src/main/java/META-INF/
trunk/ui/togglePanel/src/main/java/META-INF/MANIFEST.MF
trunk/ui/toolBar/src/main/java/META-INF/
trunk/ui/toolBar/src/main/java/META-INF/MANIFEST.MF
Removed:
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java
Modified:
trunk/framework/api/src/main/java/org/richfaces/skin/SkinFactory.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/DebugLifecycleFactory.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java
trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
Log:
append skin name parameter "org.richfaces.SKIN"
fix "lastModified" property processing for a cacheable resources.
append method "findComponentFor" to the RendererUtils method.
Modified: trunk/framework/api/src/main/java/org/richfaces/skin/SkinFactory.java
===================================================================
--- trunk/framework/api/src/main/java/org/richfaces/skin/SkinFactory.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/api/src/main/java/org/richfaces/skin/SkinFactory.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -175,9 +175,9 @@
* instance of {@link Skin } - used this instance. by default -
* "org.exadel.chameleon.SKIN"
*/
- public static final String SKIN_PARAMETER = "org.ajax4jsf.SKIN";
+ public static final String SKIN_PARAMETER = "org.richfaces.SKIN";
- public static final String BASE_SKIN_PARAMETER = "org.ajax4jsf.BASE_SKIN";
+ public static final String BASE_SKIN_PARAMETER = "org.richfaces.BASE_SKIN";
/**
* Get base {@link Skin} implementation
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/application/DebugLifecycleFactory.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/application/DebugLifecycleFactory.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/application/DebugLifecycleFactory.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -50,7 +50,7 @@
*/
private DebugLifecycle getDebugLifecycle() {
if (_debugLifecycle == null) {
- _debugLifecycle = new DebugLifecycle(_defaultFactory);
+ _debugLifecycle = new DebugLifecycle(_defaultFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE));
}
return _debugLifecycle;
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -564,17 +564,7 @@
throw new NullPointerException(
"Base component for search re-rendered compnnent is null");
}
- UIComponent target = null;
- UIComponent parent = component;
- UIComponent root = component;
- while (null == target && null != parent) {
- target = parent.findComponent(id);
- root = parent;
- parent = parent.getParent();
- }
- if (null == target) {
- target = findUIComponentBelow(root, id);
- }
+ UIComponent target = findComponentFor(component, id);
if (null != target) {
return AjaxRendererUtils.getAbsoluteId(target);
}
@@ -582,6 +572,26 @@
return id;
}
+ /**
+ * @param component
+ * @param id
+ * @return
+ */
+ private UIComponent findComponentFor(UIComponent component, String id) {
+ UIComponent target = null;
+ UIComponent parent = component;
+ UIComponent root = component;
+ while (null == target && null != parent) {
+ target = parent.findComponent(id);
+ root = parent;
+ parent = parent.getParent();
+ }
+ if (null == target) {
+ target = findUIComponentBelow(root, id);
+ }
+ return target;
+ }
+
private UIComponent findUIComponentBelow(UIComponent root,
String id) {
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/RendererUtils.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -25,11 +25,13 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import javax.faces.FacesException;
import javax.faces.application.ViewHandler;
import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.UIViewRoot;
@@ -44,16 +46,16 @@
import org.ajax4jsf.resource.Java2Dresource;
import org.ajax4jsf.util.HtmlDimensions;
-
/**
* Util class for common render operations - render passthru html attributes,
* iterate over child components etc.
+ *
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
- *
+ *
*/
public class RendererUtils {
-
+
public static final String DUMMY_FORM_ID = ":_form";
/**
* Substitutions for components properies names and HTML attributes names.
@@ -61,16 +63,18 @@
private static Map substitutions = new HashMap();
static {
- substitutions.put(HTML.class_ATTRIBUTE,"styleClass");
+ substitutions.put(HTML.class_ATTRIBUTE, "styleClass");
Arrays.sort(HTML.PASS_THRU);
Arrays.sort(HTML.PASS_THRU_BOOLEAN);
Arrays.sort(HTML.PASS_THRU_URI);
}
+
/**
* Common HTML elements and attributes names.
+ *
* @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.6 $ $Date: 2007/02/08 19:07:16 $
- *
+ *
*/
public interface HTML {
// elements
@@ -78,13 +82,13 @@
// attributes
public static final String id_ATTRIBUTE = "id";
public static final String class_ATTRIBUTE = "class";
-// public static final String STYLE_ATTRIBUTE = "style";
-// public static final String dir_ATTRIBUTE = "dir";
-// public static final String lang_ATTRIBUTE = "lang";
-// public static final String title_ATTRIBUTE = "title";
- public static final String accesskey_ATTRIBUTE = "accesskey";
- public static final String alt_ATTRIBUTE = "alt";
- public static final String cols_ATTRIBUTE = "cols";
+ // public static final String STYLE_ATTRIBUTE = "style";
+ // public static final String dir_ATTRIBUTE = "dir";
+ // public static final String lang_ATTRIBUTE = "lang";
+ // public static final String title_ATTRIBUTE = "title";
+ public static final String accesskey_ATTRIBUTE = "accesskey";
+ public static final String alt_ATTRIBUTE = "alt";
+ public static final String cols_ATTRIBUTE = "cols";
public static final String height_ATTRIBUTE = "height";
@@ -126,8 +130,8 @@
public static final String onselect_ATTRIBUTE = "onselect";
- // public static final String onsubmit_ATTRIBUTE = "onsubmit";
- public static final String onunload_ATTRIBUTE = "onunload";
+ // public static final String onsubmit_ATTRIBUTE = "onsubmit";
+ public static final String onunload_ATTRIBUTE = "onunload";
public static final String rows_ATTRIBUTE = "rows";
@@ -177,107 +181,42 @@
public static final String src_ATTRIBUTE = "src";
- //public static final String onreset_ATTRIBUTE = "onreset";
- // attributes sets.
+ // public static final String onreset_ATTRIBUTE = "onreset";
+ // attributes sets.
public static final String[] PASS_THRU = {
-// DIR_ATTRIBUTE,
-// LANG_ATTRIBUTE,
-// STYLE_ATTRIBUTE,
-// TITLE_ATTRIBUTE
- "accesskey",
- "alt",
- "cols",
- "height",
- "lang",
- "longdesc",
- "maxlength",
- "onblur",
- "onchange",
- "onclick",
- "ondblclick",
- "onfocus",
- "onkeydown",
- "onkeypress",
- "onkeyup",
- "onload",
- "onmousedown",
- "onmousemove",
- "onmouseout",
- "onmouseover",
- "onmouseup",
- "onreset",
- "onselect",
- "onsubmit",
- "onunload",
- "rows",
- "size",
- "tabindex",
- "title",
- "width",
- "dir",
- "rules",
- "frame",
- "border",
- "cellspacing",
- "cellpadding",
- "summary",
- "bgcolor",
- "usemap",
- "enctype",
- "accept-charset",
- "accept",
- "target",
- "charset",
- "coords",
- "hreflang",
- "rel",
- "rev",
- "shape",
- "disabled",
- "readonly",
- "ismap"
+ // DIR_ATTRIBUTE,
+ // LANG_ATTRIBUTE,
+ // STYLE_ATTRIBUTE,
+ // TITLE_ATTRIBUTE
+ "accesskey", "alt", "cols", "height", "lang", "longdesc",
+ "maxlength", "onblur", "onchange", "onclick", "ondblclick",
+ "onfocus", "onkeydown", "onkeypress", "onkeyup", "onload",
+ "onmousedown", "onmousemove", "onmouseout", "onmouseover",
+ "onmouseup", "onreset", "onselect", "onsubmit", "onunload",
+ "rows", "size", "tabindex", "title", "width", "dir", "rules",
+ "frame", "border", "cellspacing", "cellpadding", "summary",
+ "bgcolor", "usemap", "enctype", "accept-charset", "accept",
+ "target", "charset", "coords", "hreflang", "rel", "rev",
+ "shape", "disabled", "readonly", "ismap"
};
-
+
/**
- * HTML attributes allowed boolean-values only
+ * HTML attributes allowed boolean-values only
*/
- public static final String[] PASS_THRU_BOOLEAN = {
- "disabled",
- "declare",
- "readonly",
- "compact",
- "ismap",
- "selected",
- "checked",
- "nowrap",
- "noresize",
- "nohref",
- "noshade",
- "multiple"
- };
-
-
+ public static final String[] PASS_THRU_BOOLEAN = { "disabled",
+ "declare", "readonly", "compact", "ismap", "selected",
+ "checked", "nowrap", "noresize", "nohref", "noshade",
+ "multiple" };
+
/**
- * all HTML attributes with URI value.
+ * all HTML attributes with URI value.
*/
- public static final String[] PASS_THRU_URI = {
- "usemap",
- "background",
- "codebase",
- "cite",
- "data",
- "classid",
- "href",
- "longdesc",
- "profile",
- "src"
- };
+ public static final String[] PASS_THRU_URI = { "usemap", "background",
+ "codebase", "cite", "data", "classid", "href", "longdesc",
+ "profile", "src" };
- public static final String[] PASS_THRU_STYLES = {
- "style",
- "class",
- };
+ public static final String[] PASS_THRU_STYLES = { "style", "class", };
public static final String SPAN_ELEM = "span";
public static final String DIV_ELEM = "div";
@@ -313,107 +252,126 @@
}
/**
- * Encode id attribute with clientId component property
+ * Encode id attribute with clientId component property
+ *
* @param context
* @param component
* @throws IOException
*/
- public void encodeId(FacesContext context, UIComponent component) throws IOException {
- encodeId(context,component,HTML.id_ATTRIBUTE);
+ public void encodeId(FacesContext context, UIComponent component)
+ throws IOException {
+ encodeId(context, component, HTML.id_ATTRIBUTE);
}
-
+
/**
* Encode clientId to custom attribute ( for example, to control name )
+ *
* @param context
* @param component
* @param attribute
* @throws IOException
*/
- public void encodeId(FacesContext context,UIComponent component, String attribute) throws IOException {
+ public void encodeId(FacesContext context, UIComponent component,
+ String attribute) throws IOException {
String clientId = null;
try {
clientId = component.getClientId(context);
- } catch(Exception e) {
- //just ignore if clientId wasn't inited yet
+ } catch (Exception e) {
+ // just ignore if clientId wasn't inited yet
}
if (null != clientId) {
- context.getResponseWriter().writeAttribute(attribute,
- clientId,
- (String) getComponentAttributeName(attribute));
+ context.getResponseWriter().writeAttribute(attribute, clientId,
+ (String) getComponentAttributeName(attribute));
}
}
+
/**
- * Encode id attribute with clientId component property.
- * Encoded only if id not auto generated.
+ * Encode id attribute with clientId component property. Encoded only if id
+ * not auto generated.
+ *
* @param context
* @param component
* @throws IOException
*/
- public void encodeCustomId(FacesContext context, UIComponent component) throws IOException {
- if(component.getId() != null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)){
- context.getResponseWriter().writeAttribute(HTML.id_ATTRIBUTE,component.getClientId(context),HTML.id_ATTRIBUTE);
+ public void encodeCustomId(FacesContext context, UIComponent component)
+ throws IOException {
+ if (component.getId() != null
+ && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
+ context.getResponseWriter().writeAttribute(HTML.id_ATTRIBUTE,
+ component.getClientId(context), HTML.id_ATTRIBUTE);
}
}
-
+
/**
* Encode common pass-thru html attributes.
+ *
* @param context
* @param component
* @throws IOException
*/
- public void encodePassThru(FacesContext context, UIComponent component) throws IOException {
- encodeAttributesFromArray(context,component,HTML.PASS_THRU);
+ public void encodePassThru(FacesContext context, UIComponent component)
+ throws IOException {
+ encodeAttributesFromArray(context, component, HTML.PASS_THRU);
}
-
+
/**
* Encode pass-through attributes except specified ones
+ *
* @param context
* @param component
* @param exclusions
* @throws IOException
*/
- public void encodePassThruWithExclusions(FacesContext context, UIComponent component,String exclusions) throws IOException{
+ public void encodePassThruWithExclusions(FacesContext context,
+ UIComponent component, String exclusions) throws IOException {
if (null != exclusions) {
String[] exclusionsArray = exclusions.split(",");
- encodePassThruWithExclusionsArray(context,component,exclusionsArray);
+ encodePassThruWithExclusionsArray(context, component,
+ exclusionsArray);
}
}
- public void encodePassThruWithExclusionsArray(FacesContext context, UIComponent component,String[] exclusions) throws IOException {
+ public void encodePassThruWithExclusionsArray(FacesContext context,
+ UIComponent component, String[] exclusions) throws IOException {
ResponseWriter writer = context.getResponseWriter();
Map attributes = component.getAttributes();
Arrays.sort(exclusions);
for (int i = 0; i < HTML.PASS_THRU.length; i++) {
String attribute = HTML.PASS_THRU[i];
- if(Arrays.binarySearch(exclusions, attribute) < 0){
+ if (Arrays.binarySearch(exclusions, attribute) < 0) {
encodePassThruAttribute(context, attributes, writer, attribute);
}
}
}
/**
- * Encode one pass-thru attribute, with plain/boolean/url value, got from properly component attribute.
+ * Encode one pass-thru attribute, with plain/boolean/url value, got from
+ * properly component attribute.
+ *
* @param context
* @param component
* @param writer
* @param attribute
* @throws IOException
*/
- public void encodePassThruAttribute(FacesContext context, Map attributes, ResponseWriter writer, String attribute) throws IOException {
- Object value = attributeValue(attribute,attributes.get(getComponentAttributeName(attribute)));
+ public void encodePassThruAttribute(FacesContext context, Map attributes,
+ ResponseWriter writer, String attribute) throws IOException {
+ Object value = attributeValue(attribute, attributes
+ .get(getComponentAttributeName(attribute)));
if (null != value && shouldRenderAttribute(value)) {
- if(Arrays.binarySearch(HTML.PASS_THRU_URI, attribute)>=0){
- String url = context.getApplication().getViewHandler().getResourceURL(context, value.toString());
+ if (Arrays.binarySearch(HTML.PASS_THRU_URI, attribute) >= 0) {
+ String url = context.getApplication().getViewHandler()
+ .getResourceURL(context, value.toString());
url = context.getExternalContext().encodeResourceURL(url);
- writer.writeURIAttribute(attribute,url,attribute);
+ writer.writeURIAttribute(attribute, url, attribute);
} else {
- writer.writeAttribute(attribute,value,attribute);
+ writer.writeAttribute(attribute, value, attribute);
}
}
}
-
- public void encodeAttributesFromArray(FacesContext context, UIComponent component,String[] attrs) throws IOException {
+ public void encodeAttributesFromArray(FacesContext context,
+ UIComponent component, String[] attrs) throws IOException {
ResponseWriter writer = context.getResponseWriter();
Map attributes = component.getAttributes();
for (int i = 0; i < attrs.length; i++) {
@@ -422,76 +380,89 @@
}
}
-
/**
* Encode attributes given by comma-separated string list.
- * @param context current JSF context
- * @param component for with render attributes values
- * @param attrs comma separated list of attributes
+ *
+ * @param context
+ * current JSF context
+ * @param component
+ * for with render attributes values
+ * @param attrs
+ * comma separated list of attributes
* @throws IOException
*/
- public void encodeAttributes(FacesContext context, UIComponent component,String attrs) throws IOException {
+ public void encodeAttributes(FacesContext context, UIComponent component,
+ String attrs) throws IOException {
if (null != attrs) {
String[] attrsArray = attrs.split(",");
- encodeAttributesFromArray(context,component,attrsArray);
+ encodeAttributesFromArray(context, component, attrsArray);
}
}
+
/**
* @param context
* @param component
* @param string
* @param string2
- * @throws IOException
+ * @throws IOException
*/
- public void encodeAttribute(FacesContext context, UIComponent component, Object property, String attributeName) throws IOException {
+ public void encodeAttribute(FacesContext context, UIComponent component,
+ Object property, String attributeName) throws IOException {
ResponseWriter writer = context.getResponseWriter();
Object value = component.getAttributes().get(property);
if (shouldRenderAttribute(value)) {
- writer.writeAttribute(attributeName,value,property.toString());
+ writer.writeAttribute(attributeName, value, property.toString());
}
-
+
}
- public void encodeAttribute(FacesContext context, UIComponent component,String attribute) throws IOException {
- encodeAttribute(context,component,getComponentAttributeName(attribute),attribute);
+ public void encodeAttribute(FacesContext context, UIComponent component,
+ String attribute) throws IOException {
+ encodeAttribute(context, component,
+ getComponentAttributeName(attribute), attribute);
}
+
/**
* Write html-attribute
+ *
* @param writer
* @param attribute
* @param value
* @throws IOException
*/
- public void writeAttribute(ResponseWriter writer, String attribute, Object value ) throws IOException {
- if ( shouldRenderAttribute(value) ) {
- writer.writeAttribute(attribute, value.toString(), attribute );
+ public void writeAttribute(ResponseWriter writer, String attribute,
+ Object value) throws IOException {
+ if (shouldRenderAttribute(value)) {
+ writer.writeAttribute(attribute, value.toString(), attribute);
}
}
- /**
- * @return true if and only if the argument
- * <code>attributeVal</code> is an instance of a wrapper for a
- * primitive type and its value is equal to the default value for
- * that type as given in the spec.
- */
+ /**
+ * @return true if and only if the argument <code>attributeVal</code> is
+ * an instance of a wrapper for a primitive type and its value is
+ * equal to the default value for that type as given in the spec.
+ */
- public boolean shouldRenderAttribute(Object attributeVal) {
- if(null == attributeVal){
- return false;
- } else if (attributeVal instanceof Boolean &&
- ((Boolean) attributeVal).booleanValue() ==
- Boolean.FALSE.booleanValue()) {
- return false;
- } else if(attributeVal.toString().length() == 0){
+ public boolean shouldRenderAttribute(Object attributeVal) {
+ if (null == attributeVal) {
return false;
- } else return isValidProperty(attributeVal);
- }
-
-
+ } else if (attributeVal instanceof Boolean
+ && ((Boolean) attributeVal).booleanValue() == Boolean.FALSE
+ .booleanValue()) {
+ return false;
+ } else if (attributeVal.toString().length() == 0) {
+ return false;
+ } else
+ return isValidProperty(attributeVal);
+ }
+
/**
- * Test for valid value of property. by default, for non-setted properties with Java primitive types of
- * JSF component return appropriate MIN_VALUE .
- * @param property - value of property returned from {@link UIComponent#getAttributes()}
+ * Test for valid value of property. by default, for non-setted properties
+ * with Java primitive types of JSF component return appropriate MIN_VALUE .
+ *
+ * @param property -
+ * value of property returned from
+ * {@link UIComponent#getAttributes()}
* @return true for setted property, false otherthise.
*/
public boolean isValidProperty(Object property) {
@@ -530,7 +501,7 @@
*/
protected Object getComponentAttributeName(Object key) {
Object converted = substitutions.get(key);
- if (null==converted) {
+ if (null == converted) {
return key;
} else {
return converted;
@@ -538,41 +509,47 @@
}
/**
- * Convert attribute value to proper object. For known html boolean attributes return name
- * for true value, otherthise - null. For non-boolean attributes return same value.
- * @param name attribute name.
+ * Convert attribute value to proper object. For known html boolean
+ * attributes return name for true value, otherthise - null. For non-boolean
+ * attributes return same value.
+ *
+ * @param name
+ * attribute name.
* @param value
* @return
*/
- protected Object attributeValue(String name, Object value){
- if (null != value && Arrays.binarySearch(HTML.PASS_THRU_BOOLEAN,name)>=0) {
+ protected Object attributeValue(String name, Object value) {
+ if (null != value
+ && Arrays.binarySearch(HTML.PASS_THRU_BOOLEAN, name) >= 0) {
boolean checked = false;
if (value instanceof Boolean) {
- checked = ((Boolean) value).booleanValue();
- } else {
- if( ! (value instanceof String) ){
+ checked = ((Boolean) value).booleanValue();
+ } else {
+ if (!(value instanceof String)) {
value = value.toString();
}
checked = (new Boolean((String) value)).booleanValue();
}
- return checked?name:null;
+ return checked ? name : null;
} else {
return value;
}
}
-
-
+
/**
* Get boolean value of logical attribute
- * @param component
- * @param name attribute name
- * @return true if attribute is equals Boolean.TRUE or String "true" , false otherwise.
+ *
+ * @param component
+ * @param name
+ * attribute name
+ * @return true if attribute is equals Boolean.TRUE or String "true" , false
+ * otherwise.
*/
- public boolean isBooleanAttribute(UIComponent component, String name){
+ public boolean isBooleanAttribute(UIComponent component, String name) {
Object attrValue = component.getAttributes().get(name);
boolean result = false;
- if(null != attrValue){
- if(attrValue instanceof String ){
+ if (null != attrValue) {
+ if (attrValue instanceof String) {
result = "true".equalsIgnoreCase((String) attrValue);
} else {
result = Boolean.TRUE.equals(attrValue);
@@ -580,10 +557,11 @@
}
return result;
}
-
+
/**
- * Return converted value for {@link javax.faces.component.ValueHolder} as String,
- * perform nessesary convertions.
+ * Return converted value for {@link javax.faces.component.ValueHolder} as
+ * String, perform nessesary convertions.
+ *
* @param context
* @param component
* @return
@@ -593,27 +571,33 @@
if (component instanceof EditableValueHolder) {
EditableValueHolder input = (EditableValueHolder) component;
String submittedValue = (String) input.getSubmittedValue();
- if(null != submittedValue) {
+ if (null != submittedValue) {
return submittedValue;
}
}
// If no submitted value presented - convert same for UIInput/UIOutput
if (component instanceof ValueHolder) {
- return formatValue(context, component, ((ValueHolder) component).getValue() );
+ return formatValue(context, component, ((ValueHolder) component)
+ .getValue());
} else {
- throw new IllegalArgumentException(Messages.getMessage(Messages.CONVERTING_NON_VALUE_HOLDER_COMPONENT_ERROR, component.getId()));
+ throw new IllegalArgumentException(Messages.getMessage(
+ Messages.CONVERTING_NON_VALUE_HOLDER_COMPONENT_ERROR,
+ component.getId()));
}
}
/**
- * Convert any object value to string. If component instance of {@link ValueHolder } got {@link Converter} for formatting.
- * If not, attempt to use converter based on value type.
+ * Convert any object value to string. If component instance of
+ * {@link ValueHolder } got {@link Converter} for formatting. If not,
+ * attempt to use converter based on value type.
+ *
* @param context
* @param component
* @return
*/
- public String formatValue(FacesContext context, UIComponent component,Object value) {
- if(value instanceof String) {
+ public String formatValue(FacesContext context, UIComponent component,
+ Object value) {
+ if (value instanceof String) {
return (String) value;
}
Converter converter = null;
@@ -621,7 +605,7 @@
ValueHolder holder = (ValueHolder) component;
converter = holder.getConverter();
}
- if(null == converter && null != value ) {
+ if (null == converter && null != value) {
try {
converter = context.getApplication().createConverter(
value.getClass());
@@ -629,8 +613,8 @@
// TODO - log converter exception.
}
}
- if(null == converter) {
- if(null != value) {
+ if (null == converter) {
+ if (null != value) {
return value.toString();
}
} else {
@@ -638,68 +622,73 @@
}
return "";
}
-
- public void encodeDimensions(FacesContext context, UIComponent component, InternetResource resource) throws IOException {
+
+ public void encodeDimensions(FacesContext context, UIComponent component,
+ InternetResource resource) throws IOException {
if (resource instanceof Java2Dresource) {
Java2Dresource j2d = (Java2Dresource) resource;
Dimension dim = j2d.getDimensions(context, component);
ResponseWriter writer = context.getResponseWriter();
writer.writeAttribute("width", String.valueOf(dim.width), "width");
- writer.writeAttribute("height", String.valueOf(dim.height), "height");
+ writer.writeAttribute("height", String.valueOf(dim.height),
+ "height");
}
}
- public String encodePx(String value){
+
+ public String encodePx(String value) {
return HtmlDimensions.formatPx(HtmlDimensions.decode(value));
}
+
/**
- * formats given value to
+ * formats given value to
+ *
* @param value
* @param pattern
* @return
*/
- public String encodePctOrPx(String value){
- if(value.indexOf('%') > 0){
+ public String encodePctOrPx(String value) {
+ if (value.indexOf('%') > 0) {
return value;
} else {
return encodePx(value);
}
}
-
- /**
- * Find nested form for given component
- * @param component
- * @return nested <code>UIForm</code> component, or <code>null</code>
- */
- public UIForm getNestingForm(FacesContext context,UIComponent component)
- {
- UIComponent parent = component.getParent();
- while (parent != null && !(parent instanceof UIForm))
- {
- parent = parent.getParent();
- }
- UIForm nestingForm = null;
- if (parent != null)
- {
- //link is nested inside a form
- nestingForm = (UIForm) parent;
- }
- return nestingForm;
- }
+ /**
+ * Find nested form for given component
+ *
+ * @param component
+ * @return nested <code>UIForm</code> component, or <code>null</code>
+ */
+ public UIForm getNestingForm(FacesContext context, UIComponent component) {
+ UIComponent parent = component.getParent();
+ while (parent != null && !(parent instanceof UIForm)) {
+ parent = parent.getParent();
+ }
+ UIForm nestingForm = null;
+ if (parent != null) {
+ // link is nested inside a form
+ nestingForm = (UIForm) parent;
+ }
+ return nestingForm;
+ }
+
/**
* @param context
* @param component
* @return
- * @throws IOException
+ * @throws IOException
*/
- public void encodeBeginFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
+ public void encodeBeginFormIfNessesary(FacesContext context,
+ UIComponent component) throws IOException {
UIForm form = getNestingForm(context, component);
- if(null == form) {
- ResponseWriter writer = context.getResponseWriter();
- String clientId = component.getClientId(context)+DUMMY_FORM_ID;
- encodeBeginForm(context, component, writer, clientId);
-// writer.writeAttribute(HTML.style_ATTRIBUTE, "margin:0; padding:0;", null);
+ if (null == form) {
+ ResponseWriter writer = context.getResponseWriter();
+ String clientId = component.getClientId(context) + DUMMY_FORM_ID;
+ encodeBeginForm(context, component, writer, clientId);
+ // writer.writeAttribute(HTML.style_ATTRIBUTE, "margin:0;
+ // padding:0;", null);
}
}
@@ -710,31 +699,34 @@
* @param clientId
* @throws IOException
*/
- public void encodeBeginForm(FacesContext context, UIComponent component, ResponseWriter writer, String clientId) throws IOException {
+ public void encodeBeginForm(FacesContext context, UIComponent component,
+ ResponseWriter writer, String clientId) throws IOException {
String actionURL = getActionUrl(context);
- String encodeActionURL = context.getExternalContext().encodeActionURL(actionURL);
+ String encodeActionURL = context.getExternalContext().encodeActionURL(
+ actionURL);
writer.startElement(HTML.FORM_ELEMENT, component);
writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, null);
writer.writeAttribute(HTML.NAME_ATTRIBUTE, clientId, null);
writer.writeAttribute(HTML.METHOD_ATTRIBUTE, "post", null);
- writer.writeAttribute(HTML.style_ATTRIBUTE, "margin:0; padding:0;", null);
- writer.writeURIAttribute(HTML.ACTION_ATTRIBUTE,
- encodeActionURL,
- "action");
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "margin:0; padding:0;",
+ null);
+ writer.writeURIAttribute(HTML.ACTION_ATTRIBUTE, encodeActionURL,
+ "action");
}
/**
* @param context
* @param component
- * @throws IOException
+ * @throws IOException
*/
- public void encodeEndFormIfNessesary(FacesContext context, UIComponent component) throws IOException {
+ public void encodeEndFormIfNessesary(FacesContext context,
+ UIComponent component) throws IOException {
UIForm form = getNestingForm(context, component);
- if(null == form) {
- ResponseWriter writer = context.getResponseWriter();
+ if (null == form) {
+ ResponseWriter writer = context.getResponseWriter();
// TODO - hidden form parameters ?
- encodeEndForm(context, writer);
+ encodeEndForm(context, writer);
}
}
@@ -743,64 +735,118 @@
* @param writer
* @throws IOException
*/
- public void encodeEndForm(FacesContext context, ResponseWriter writer) throws IOException {
+ public void encodeEndForm(FacesContext context, ResponseWriter writer)
+ throws IOException {
AjaxRendererUtils.writeState(context);
writer.endElement(HTML.FORM_ELEMENT);
}
- /**
- * @param facesContext
- * @return String A String representing the action URL
- */
- public String getActionUrl(FacesContext facesContext)
- {
- ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
- String viewId = facesContext.getViewRoot().getViewId();
- return viewHandler.getActionURL(facesContext, viewId);
- }
- /**
- *
- * @param context
- * @param value
- * @return URL of target resource (src, href, etc)
- */
- public String encodeResourceURL(TemplateContext context, Object value){
- if(value == null){
- return "";
- }
- FacesContext facesContext = context.getFacesContext();
- value = facesContext.getApplication().getViewHandler().getResourceURL(facesContext, value.toString());
- return facesContext.getExternalContext().encodeResourceURL((String)value);
- }
- /**
- * Simplified version of {@link encodeId}
- * @param context
- * @param component
- * @return client id of current component
- */
- public String clientId(FacesContext context, UIComponent component){
- String clientId = "";
- try {
+ /**
+ * @param facesContext
+ * @return String A String representing the action URL
+ */
+ public String getActionUrl(FacesContext facesContext) {
+ ViewHandler viewHandler = facesContext.getApplication()
+ .getViewHandler();
+ String viewId = facesContext.getViewRoot().getViewId();
+ return viewHandler.getActionURL(facesContext, viewId);
+ }
+
+ /**
+ *
+ * @param context
+ * @param value
+ * @return URL of target resource (src, href, etc)
+ */
+ public String encodeResourceURL(TemplateContext context, Object value) {
+ if (value == null) {
+ return "";
+ }
+ FacesContext facesContext = context.getFacesContext();
+ value = facesContext.getApplication().getViewHandler().getResourceURL(
+ facesContext, value.toString());
+ return facesContext.getExternalContext().encodeResourceURL(
+ (String) value);
+ }
+
+ /**
+ * Simplified version of {@link encodeId}
+ *
+ * @param context
+ * @param component
+ * @return client id of current component
+ */
+ public String clientId(FacesContext context, UIComponent component) {
+ String clientId = "";
+ try {
clientId = component.getClientId(context);
} catch (Exception e) {
- //just ignore
+ // just ignore
}
return clientId;
- }
+ }
/**
* Wtrie JavaScript with start/end elements and type.
+ *
* @param context
* @param tab
* @param string
*/
- public void writeScript(FacesContext context, UIComponent component, Object script) throws IOException {
+ public void writeScript(FacesContext context, UIComponent component,
+ Object script) throws IOException {
ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.SCRIPT_ELEM,component);
- writer.writeAttribute(HTML.TYPE_ATTR,"text/javascript","type");
- writer.writeText(script,null);
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", "type");
+ writer.writeText(script, null);
writer.endElement(HTML.SCRIPT_ELEM);
}
+ /**
+ * @param component
+ * @param id
+ * @return
+ */
+ public UIComponent findComponentFor(FacesContext context,
+ UIComponent component, String id) {
+ UIComponent target = null;
+ UIComponent parent = component;
+ UIComponent root = component;
+ while (null == target && null != parent) {
+ target = parent.findComponent(id);
+ root = parent;
+ parent = parent.getParent();
+ }
+ if (null == target) {
+ target = findUIComponentBelow(root, id);
+ }
+ return target;
+ }
+
+ private UIComponent findUIComponentBelow(UIComponent root, String id) {
+ UIComponent target = null;
+ for (Iterator iter = root.getFacetsAndChildren(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof NamingContainer) {
+ try {
+ target = child.findComponent(id);
+ } catch (IllegalArgumentException iae) {
+ continue;
+ }
+ }
+ if (target == null) {
+ if (child.getChildCount() > 0) {
+ target = findUIComponentBelow(child, id);
+ }
+ }
+
+ if (target != null) {
+ break;
+ }
+
+ }
+ return target;
+ }
+
}
\ No newline at end of file
Copied: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheContext.java (from rev 2057, trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java)
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheContext.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheContext.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.ajax4jsf.resource;
+
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 01.05.2007
+ *
+ */
+public class CacheContext {
+ private CachedResourceContext resourceContext;
+ private InternetResource resource;
+ public CacheContext(CachedResourceContext resourceContext,
+ InternetResource resource) {
+ super();
+ this.resourceContext = resourceContext;
+ this.resource = resource;
+ }
+ /**
+ * @return the resourceContext
+ */
+ public CachedResourceContext getResourceContext() {
+ return resourceContext;
+ }
+ public InternetResource getResource() {
+ return resource;
+ }
+
+}
Deleted: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/CacheKey.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -1,43 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.resource;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ajax4jsf.resource.InternetResource;
-
-/**
- * @author Nick - mailto:nbelaevski@exadel.com
- * created 01.05.2007
- *
- */
-public class CacheKey {
- private Object resourceData;
- private HttpServletRequest request;
- private HttpServletResponse response;
- private InternetResource resource;
- public CacheKey(Object resourceData,
- HttpServletRequest request, HttpServletResponse response,
- InternetResource resource) {
- super();
- this.resourceData = resourceData;
- this.request = request;
- this.response = response;
- this.resource = resource;
- }
- public Object getResourceData() {
- return resourceData;
- }
- public HttpServletRequest getRequest() {
- return request;
- }
- public HttpServletResponse getResponse() {
- return response;
- }
- public InternetResource getResource() {
- return resource;
- }
-
-}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/ClientScript.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -82,7 +82,7 @@
*/
public Date getLastModified(ResourceContext resourceContext) {
- if (isCacheable(null)) {
+ if (isCacheable(resourceContext)) {
return super.getLastModified(resourceContext);
} else {
return new Date(System.currentTimeMillis()+1000L);
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceBase.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -59,7 +59,7 @@
private int contentLength = -1;
- private Date lastModified;
+ private Date lastModified = new Date(System.currentTimeMillis());
private Date expired;
@@ -383,7 +383,7 @@
* @see org.ajax4jsf.chameleon.resource.InternetResource#sendHeaders(javax.servlet.http.HttpServletResponse)
*/
public void sendHeaders(ResourceContext context) {
- boolean cached = context.isCacheEnabled() && isCacheable(null);
+ boolean cached = context.isCacheEnabled() && isCacheable(context);
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage(Messages.SET_RESPONSE_HEADERS_INFO,
getKey()));
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/InternetResourceService.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -57,324 +57,288 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+public class InternetResourceService implements CacheLoader,
+ CacheConfigurationLoader {
+ private static final Log log = LogFactory
+ .getLog(InternetResourceService.class);
-public class InternetResourceService implements CacheLoader, CacheConfigurationLoader {
- private static final Log log = LogFactory
- .getLog(InternetResourceService.class);
+ static final String ENABLE_CACHING_PARAMETER = "enable-cache";
- static final String ENABLE_CACHING_PARAMETER = "enable-cache";
+ private static final String RESOURCE_LIFECYCLE_PARAMETER = "org.ajax4jsf.RESOURCE_LIFECYCLE";
- private static final String RESOURCE_LIFECYCLE_PARAMETER = "org.ajax4jsf.RESOURCE_LIFECYCLE";
+ private FilterConfig filterConfig;
- private FilterConfig filterConfig;
+ private boolean cacheEnabled = true;
- private boolean cacheEnabled = true;
+ private Cache cache = null;
- private Cache cache = null;
-
- //private ServletCacheAdministrator cacheAdmin;
+ // private ServletCacheAdministrator cacheAdmin;
- private FacesContextFactory contextFactory;
+ private FacesContextFactory contextFactory;
- // private RenderKitFactory renderKitFactory;
- private String lifecycleClass;
+ // private RenderKitFactory renderKitFactory;
+ private String lifecycleClass;
- private ResourceLifecycle lifecycle;
+ private ResourceLifecycle lifecycle;
- private InternetResourceBuilder resourceBuilder;
-
- private WebXml webXml;
+ private InternetResourceBuilder resourceBuilder;
- public InternetResourceService() {
- }
+ private WebXml webXml;
- public void setCacheEnabled(boolean b) {
- cacheEnabled = b;
- }
+ public InternetResourceService() {
+ }
- public void init(FilterConfig config) throws ServletException {
- filterConfig = config;
- ServletContext servletContext = config.getServletContext();
- if ("false".equalsIgnoreCase(config
- .getInitParameter(ENABLE_CACHING_PARAMETER))) {
- setCacheEnabled(false);
- // this.cacheEnabled = false;
- //this.cacheAdmin = null;
- } else {
- //this.cacheAdmin = ServletCacheAdministrator.getInstance(
- // servletContext, cacheProperties);
- try {
- CacheManager cacheManager = CacheManager.getInstance();
- Map env = new ServletContextInitMap(servletContext);
- CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
- this.cache = cacheFactory.createCache(env, this, this);
- } catch (CacheException e) {
- throw new FacesException(e.getMessage(), e);
- }
+ public void setCacheEnabled(boolean b) {
+ cacheEnabled = b;
}
- // Create Resource-specific Faces Lifecycle instance.
- lifecycleClass = servletContext
- .getInitParameter(RESOURCE_LIFECYCLE_PARAMETER);
- if (lifecycleClass != null) {
- ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- Class clazz = classLoader.loadClass(lifecycleClass);
- lifecycle = (ResourceLifecycle) clazz.newInstance();
- } catch (Exception e) {
- throw new FacesException(
- "Error create instance of resource Lifecycle "
- + lifecycleClass, e);
- }
- } else {
- lifecycle = new ResourceLifecycle();
- }
- webXml = new WebXml();
- webXml.init(servletContext,filterConfig.getFilterName());
- if (log.isDebugEnabled()) {
- log.debug("Resources service initialized");
- }
- }
- public boolean serviceResource(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse) throws ServletException,
- IOException {
- String resourceKey = webXml
- .getFacesResourceKey(httpServletRequest);
- if (null != resourceKey) {
- serviceResource(resourceKey, httpServletRequest,
- httpServletResponse);
- return true;
+ public void init(FilterConfig config) throws ServletException {
+ filterConfig = config;
+ ServletContext servletContext = config.getServletContext();
+ if ("false".equalsIgnoreCase(config
+ .getInitParameter(ENABLE_CACHING_PARAMETER))) {
+ setCacheEnabled(false);
+ // this.cacheEnabled = false;
+ // this.cacheAdmin = null;
+ } else {
+ // this.cacheAdmin = ServletCacheAdministrator.getInstance(
+ // servletContext, cacheProperties);
+ try {
+ CacheManager cacheManager = CacheManager.getInstance();
+ Map env = new ServletContextInitMap(servletContext);
+ CacheFactory cacheFactory = cacheManager.getCacheFactory(env);
+ this.cache = cacheFactory.createCache(env, this, this);
+ } catch (CacheException e) {
+ throw new FacesException(e.getMessage(), e);
+ }
+ }
+ // Create Resource-specific Faces Lifecycle instance.
+ lifecycleClass = servletContext
+ .getInitParameter(RESOURCE_LIFECYCLE_PARAMETER);
+ if (lifecycleClass != null) {
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ try {
+ Class clazz = classLoader.loadClass(lifecycleClass);
+ lifecycle = (ResourceLifecycle) clazz.newInstance();
+ } catch (Exception e) {
+ throw new FacesException(
+ "Error create instance of resource Lifecycle "
+ + lifecycleClass, e);
+ }
+ } else {
+ lifecycle = new ResourceLifecycle();
+ }
+ webXml = new WebXml();
+ webXml.init(servletContext, filterConfig.getFilterName());
+ if (log.isDebugEnabled()) {
+ log.debug("Resources service initialized");
+ }
}
- return false;
- }
- public void serviceResource(String resourceKey, HttpServletRequest request,
- HttpServletResponse response) throws ServletException, IOException {
- InternetResource resource;// getInternetResource(request);
- try {
- resource = getResourceBuilder().getResourceForKey(resourceKey);
- } catch (ResourceNotFoundException e) {
- throw new ServletException(e);
+ public boolean serviceResource(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse) throws ServletException,
+ IOException {
+ String resourceKey = webXml.getFacesResourceKey(httpServletRequest);
+ if (null != resourceKey) {
+ serviceResource(resourceKey, httpServletRequest,
+ httpServletResponse);
+ return true;
+ }
+ return false;
}
- Object resourceDataForKey = getResourceBuilder()
- .getResourceDataForKey(resourceKey);
- if (resource.isCacheable(null) && this.cacheEnabled) {
- // Test for client request modification time.
- try {
- long ifModifiedSince = request
- .getDateHeader("If-Modified-Since");
- if (ifModifiedSince >= 0) {
- // Test for modification. 1000 ms due to round
- // modification
- // time to seconds.
- long lastModified = resource.getLastModified(null)
- .getTime() - 1000;
- if (lastModified <= ifModifiedSince) {
- response.setStatus(304);
- return;
- }
+
+ public void serviceResource(String resourceKey, HttpServletRequest request,
+ HttpServletResponse response) throws ServletException, IOException {
+ InternetResource resource;// getInternetResource(request);
+ try {
+ resource = getResourceBuilder().getResourceForKey(resourceKey);
+ } catch (ResourceNotFoundException e) {
+ throw new ServletException(e);
}
- } catch (IllegalArgumentException e) {
- log
- .warn(
- Messages
- .getMessage(Messages.PARSING_IF_MODIFIED_SINCE_WARNING),
- e);
- }
- String cacheKey = resourceKey;// + "?" +
- // request.getQueryString();
- // TODO - select session/application scope.
- //Cache cache = cacheAdmin.getAppScopeCache(getServletContext());
-// try {
- // TODO - use last modified/expires time
-
- CacheKey key = new CacheKey(resourceDataForKey, request, response, resource);
-
- CacheContent content;
+ Object resourceDataForKey = getResourceBuilder().getResourceDataForKey(
+ resourceKey);
+
+ ResourceContext resourceContext = getResourceContext(resource, request,
+ response);
+ resourceContext.setResourceData(resourceDataForKey);
try {
- content = (CacheContent) cache
- .get(cacheKey, key);
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.GET_CONTENT_FROM_CACHE_INFO, cacheKey));
- }
- content.sendHeaders(response);
- // Correct expires date for resource.
- Date expired = resource.getExpired(null);
- if (expired != null) {
- response.setDateHeader("Expires", expired.getTime());
+
+ if (resource.isCacheable(resourceContext) && this.cacheEnabled) {
+ // Test for client request modification time.
+ try {
+ long ifModifiedSince = request
+ .getDateHeader("If-Modified-Since");
+ if (ifModifiedSince >= 0) {
+ // Test for modification. 1000 ms due to round
+ // modification
+ // time to seconds.
+ long lastModified = resource.getLastModified(
+ resourceContext).getTime() - 1000;
+ if (lastModified <= ifModifiedSince) {
+ response.setStatus(304);
+ return;
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ log
+ .warn(
+ Messages
+ .getMessage(Messages.PARSING_IF_MODIFIED_SINCE_WARNING),
+ e);
+ }
+ String cacheKey = resourceKey;
+ CachedResourceContext cachedResourceContext = new CachedResourceContext(
+ resourceContext);
+
+ CacheContext cacheLoaderContext = new CacheContext(
+ cachedResourceContext, resource);
+
+ try {
+ CacheContent content = (CacheContent) cache.get(cacheKey,
+ cacheLoaderContext);
+ if (log.isDebugEnabled()) {
+ log
+ .debug(Messages.getMessage(
+ Messages.GET_CONTENT_FROM_CACHE_INFO,
+ cacheKey));
+ }
+ content.sendHeaders(response);
+ // Correct expires date for resource.
+ Date expired = resource.getExpired(resourceContext);
+ if (expired != null) {
+ response.setDateHeader("Expires", expired.getTime());
+ } else {
+ response.setDateHeader("Expires", System
+ .currentTimeMillis()
+ + InternetResource.DEFAULT_EXPIRE);
+ }
+ if (!request.getMethod().equals("HEAD")) {
+ content.send(response);
+ }
+ } catch (CacheException e) {
+ log.error(
+ Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
+ e);
+ throw new ServletException(Messages.getMessage(
+ Messages.SEND_RESOURCE_ERROR_2, e.getMessage()), e);
+ }
} else {
- response.setDateHeader("Expires", System
- .currentTimeMillis()
- + InternetResource.DEFAULT_EXPIRE);
+ getLifecycle().send(resourceContext, resource);
+ // sendResource(resource, request, response,
+ // resourceDataForKey);
}
- if (!request.getMethod().equals("HEAD")) {
- content.send(response);
- }/*
- } catch (NeedsRefreshException e) {
- try {
- if (log.isDebugEnabled()) {
- log.debug(Messages.getMessage(
- Messages.CONTENT_NOT_FOUND_ERROR, cacheKey));
- }
- CachedResourceContext context = (CachedResourceContext) sendResource(
- resource, request, response, resourceDataForKey);
- // TODO - set refresh interval ?
- cache.put(cacheKey, context.getContent());
- } catch (Exception ex) {
- //cache.cancelUpdate(cacheKey);
- log.error(
- Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
- ex);
- throw new ServletException(Messages.getMessage(
- Messages.SEND_RESOURCE_ERROR_2, ex.getMessage()),
- ex);
- }
- }*/
- } catch (CacheException e) {
- log.error(
- Messages.getMessage(Messages.SEND_RESOURCE_ERROR),
- e);
- throw new ServletException(Messages.getMessage(
- Messages.SEND_RESOURCE_ERROR_2, e.getMessage()),
- e);
+
+ } finally {
+ resourceContext.release();
}
- } else {
- sendResource(resource, request, response, resourceDataForKey);
}
- }
- /**
- * @param resource
- * @param request
- * @param response
- * @throws IOException
- */
- protected ResourceContext sendResource(InternetResource resource,
- HttpServletRequest request, HttpServletResponse response,
- Object data) throws IOException {
- ResourceContext resourceContext = getResourceContext(resource, request,
- response);
- resourceContext.setResourceData(data);
- getLifecycle().send(resourceContext, resource);
- resourceContext.release();
- return resourceContext;
- }
-
- /**
- * @param resource
- * @param request
- * @param response
- * @return
- * @throws ServletException
- * @throws FacesException
- */
- protected ResourceContext getResourceContext(InternetResource resource,
- HttpServletRequest request, HttpServletResponse response)
- throws FacesException {
- FacesContext facesContext = null;
- ResourceContext resourceContext;
- if (resource.requireFacesContext()) {
- facesContext = getFacesContext(request, response);
- resourceContext = new FacesResourceContext(facesContext);
- } else {
- resourceContext = new ServletResourceContext(getServletContext(),
- request, response);
+ /**
+ * @param resource
+ * @param request
+ * @param response
+ * @return
+ * @throws ServletException
+ * @throws FacesException
+ */
+ protected ResourceContext getResourceContext(InternetResource resource,
+ HttpServletRequest request, HttpServletResponse response)
+ throws FacesException {
+ FacesContext facesContext = null;
+ ResourceContext resourceContext;
+ if (resource.requireFacesContext()) {
+ facesContext = getFacesContext(request, response);
+ resourceContext = new FacesResourceContext(facesContext);
+ } else {
+ resourceContext = new ServletResourceContext(getServletContext(),
+ request, response);
+ }
+ return resourceContext;
}
- if (resource.isCacheable(null) && this.cacheEnabled) {
- resourceContext = new CachedResourceContext(resourceContext);
- }
- return resourceContext;
- }
- /**
- * Get properties file from classpath
- *
- * @param name
- * @return
- */
- protected Properties getProperties(String name) {
- Properties properties = new Properties();
- InputStream props = BaseFilter.class.getResourceAsStream(name);
- if (null != props) {
- try {
- properties.load(props);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
- name), e);
- } finally {
- try {
- props.close();
- } catch (IOException e) {
- // Can be ignored
+ /**
+ * Get properties file from classpath
+ *
+ * @param name
+ * @return
+ */
+ protected Properties getProperties(String name) {
+ Properties properties = new Properties();
+ InputStream props = BaseFilter.class.getResourceAsStream(name);
+ if (null != props) {
+ try {
+ properties.load(props);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ log.warn(Messages.getMessage(Messages.READING_PROPERTIES_ERROR,
+ name), e);
+ } finally {
+ try {
+ props.close();
+ } catch (IOException e) {
+ // Can be ignored
+ }
+ }
}
- }
+ return properties;
+
}
- return properties;
- }
+ /**
+ * @return Returns the servletContext.
+ */
+ protected ServletContext getServletContext() {
+ return filterConfig.getServletContext();
+ }
- /**
- * @return Returns the servletContext.
- */
- protected ServletContext getServletContext() {
- return filterConfig.getServletContext();
- }
+ /**
+ * @return the lifecycle
+ * @throws ServletException
+ */
+ protected ResourceLifecycle getLifecycle() throws FacesException {
+ return lifecycle;
+ }
- /**
- * @return the lifecycle
- * @throws ServletException
- */
- protected ResourceLifecycle getLifecycle() throws FacesException {
- return lifecycle;
- }
+ /**
+ * @return the contextFactory
+ */
+ protected synchronized FacesContextFactory getContextFactory() {
+ if (contextFactory == null) {
+ contextFactory = (FacesContextFactory) FactoryFinder
+ .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ }
- /**
- * @return the contextFactory
- */
- protected synchronized FacesContextFactory getContextFactory() {
- if (contextFactory == null) {
- contextFactory = (FacesContextFactory) FactoryFinder
- .getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ return contextFactory;
}
- return contextFactory;
- }
+ protected FacesContext getFacesContext(ServletRequest request,
+ ServletResponse response) throws FacesException {
+ return getContextFactory().getFacesContext(getServletContext(),
+ request, response, getLifecycle());
+ }
- protected FacesContext getFacesContext(ServletRequest request,
- ServletResponse response) throws FacesException {
- return getContextFactory().getFacesContext(getServletContext(),
- request, response, getLifecycle());
- }
-
- /**
- * @return the resourceBuilder
- */
- protected InternetResourceBuilder getResourceBuilder() {
- if (resourceBuilder == null) {
- // Create resource builder for this filter.
- resourceBuilder = InternetResourceBuilder.getInstance();
+ /**
+ * @return the resourceBuilder
+ */
+ protected InternetResourceBuilder getResourceBuilder() {
+ if (resourceBuilder == null) {
+ // Create resource builder for this filter.
+ resourceBuilder = InternetResourceBuilder.getInstance();
+ }
+ return resourceBuilder;
}
- return resourceBuilder;
- }
public Object load(Object key, Object context) throws CacheException {
- CacheKey cacheKey = (CacheKey) context;
-
- CachedResourceContext resourceContext = (CachedResourceContext) getResourceContext(cacheKey.getResource(), cacheKey.getRequest(),
- cacheKey.getResponse());
- resourceContext.setResourceData(cacheKey.getResourceData());
- try {
- getLifecycle().send(resourceContext, cacheKey.getResource());
- } catch (IOException e) {
- throw new CacheException(e.getMessage(), e);
- }
- resourceContext.release();
-
- // TODO - set refresh interval ?
- //cache.put(cacheKey, resourceContext.getContent());
+ CacheContext cacheKey = (CacheContext) context;
+ CachedResourceContext resourceContext = cacheKey.getResourceContext();
+ try {
+ getLifecycle().send(resourceContext, cacheKey.getResource());
+ } catch (IOException e) {
+ throw new CacheException(e.getMessage(), e);
+ }
+ // TODO - set refresh interval ?
+ // cache.put(cacheKey, resourceContext.getContent());
return resourceContext.getContent();
}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/JarResource.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -21,7 +21,11 @@
package org.ajax4jsf.resource;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Date;
import org.ajax4jsf.resource.ResourceContext;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/resource/TemplateCSSResource.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -156,7 +156,7 @@
* @see org.ajax4jsf.resource.InternetResource#getLastModified(ResourceContext)
*/
public Date getLastModified(ResourceContext resourceContext) {
- return _resource.getLastModified(null);
+ return _resource.getLastModified(resourceContext);
}
/**
@@ -192,7 +192,7 @@
* @see org.ajax4jsf.resource.InternetResource#isCacheable(ResourceContext)
*/
public boolean isCacheable(ResourceContext resourceContext) {
- return _resource.isCacheable(null);
+ return _resource.isCacheable(resourceContext);
}
/**
Modified: trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/java/org/richfaces/skin/SkinFactoryImpl.java 2007-08-04 01:05:53 UTC (rev 2060)
@@ -46,9 +46,11 @@
import org.richfaces.skin.SkinNotFoundException;
/**
- * Implementation of {@link SkinFactory} with building skins from properties files.
+ * Implementation of {@link SkinFactory} with building skins from properties
+ * files.
+ *
* @author shura
- *
+ *
*/
public class SkinFactoryImpl extends SkinFactory {
@@ -75,12 +77,15 @@
* definitions. in this realisation "META-INF/skins/" for vendor , "" -
* user-defined.
*/
- private static final String[] SKINS_PATHS = { "META-INF/skins/%s.skin.properties", "%s.skin.properties" };
+ private static final String[] SKINS_PATHS = {
+ "META-INF/skins/%s.skin.properties", "%s.skin.properties" };
private static final String[] DEFAULT_SKIN_PATHS = { DEFAULT_SKIN_PROPERTIES_RESOURCE };
- private static final String[] CONFIGURATIONS_PATHS = { "META-INF/skins/%s.configuration.properties", "%s.configuration.properties" };
+ 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 Map skins = Collections.synchronizedMap(new HashMap());
private Properties defaultSkinProperties = null;
private String skinName = null;
@@ -89,6 +94,10 @@
private ValueBinding baseSkinBinding = null;
private static final Log log = LogFactory.getLog(SkinFactoryImpl.class);
+ private static final String A4J_BASE_SKIN_PARAMETER = "org.ajax4jsf.BASE_SKIN";
+
+ private static final String A4J_SKIN_PARAMETER = "org.ajax4jsf.SKIN";
+
protected Skin getSkinByName(Object currentSkinOrName) {
if (null == currentSkinOrName) {
throw new SkinNotFoundException(Messages
@@ -110,14 +119,14 @@
currentSkin = buildSkin(currentSkinName, getDefaultSkinProperties());
skins.put(currentSkinName, currentSkin);
}
-
+
return currentSkin;
}
public Skin getDefaultSkin(FacesContext context) {
return getSkinByName(DEFAULT_SKIN_NAME);
}
-
+
public Skin getSkin(FacesContext context) {
// TODO - cache skin for current thread ? or for current Faces Lifecycle
// Phase ?
@@ -144,8 +153,7 @@
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Properties defaultProperties = new Properties();
try {
- Enumeration properties = loader
- .getResources(path);
+ Enumeration properties = loader.getResources(path);
while (properties.hasMoreElements()) {
URL url = (URL) properties.nextElement();
InputStream propertyStream = null;
@@ -155,8 +163,8 @@
} catch (IOException e) {
// DO Nothing...
log.info(Messages.getMessage(
- Messages.DEFAULT_PROPERTIES_NOT_FOUND_ERROR,
- path), e);
+ Messages.DEFAULT_PROPERTIES_NOT_FOUND_ERROR, path),
+ e);
continue;
} finally {
if (null != propertyStream) {
@@ -166,8 +174,7 @@
}
} catch (IOException e) {
log.info(Messages.getMessage(
- Messages.DEFAULT_PROPERTIES_NOT_FOUND_ERROR,
- path), e);
+ Messages.DEFAULT_PROPERTIES_NOT_FOUND_ERROR, path), e);
}
return defaultProperties;
}
@@ -195,10 +202,23 @@
binding = skinBinding;
skin = skinName;
}
-
+
if (binding == null && skin == null) {
String currentSkinName = context.getExternalContext()
- .getInitParameter(useBase ? BASE_SKIN_PARAMETER : SKIN_PARAMETER);
+ .getInitParameter(
+ useBase ? BASE_SKIN_PARAMETER : SKIN_PARAMETER);
+ if (null == currentSkinName) {
+ // Check for a old ( deprecated ) parameter name.
+ currentSkinName = context.getExternalContext()
+ .getInitParameter(
+ useBase ? A4J_BASE_SKIN_PARAMETER
+ : A4J_SKIN_PARAMETER);
+ if (null != currentSkinName) {
+ log.warn("Init parameter for a skin name changed to "+ (useBase ? A4J_BASE_SKIN_PARAMETER
+ : A4J_SKIN_PARAMETER));
+ }
+
+ }
if (currentSkinName == null) {
// not set - usr default.
return DEFAULT_SKIN_NAME;
@@ -211,7 +231,7 @@
skin = currentSkinName;
}
}
-
+
if (useBase) {
baseSkinBinding = binding;
baseSkinName = skin;
@@ -219,7 +239,7 @@
skinBinding = binding;
skinName = skin;
}
-
+
// }
}
if (binding != null) {
@@ -243,8 +263,9 @@
* @throws SkinNotFoundException -
* if no skin properies found for name.
*/
- protected Skin buildSkin(String name, Properties defaultProperties) throws SkinNotFoundException {
- Map skinParams = loadProperties(name, defaultProperties,SKINS_PATHS);
+ protected Skin buildSkin(String name, Properties defaultProperties)
+ throws SkinNotFoundException {
+ Map skinParams = loadProperties(name, defaultProperties, SKINS_PATHS);
return new SkinImpl(skinParams);
}
@@ -256,7 +277,9 @@
* @throws FacesException
* @throws ReferenceSyntaxException
*/
- protected Map loadProperties(String name, Properties defaultProperties,String[] paths) throws SkinNotFoundException, FacesException, ReferenceSyntaxException {
+ protected Map loadProperties(String name, Properties defaultProperties,
+ String[] paths) throws SkinNotFoundException, FacesException,
+ ReferenceSyntaxException {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
// Get properties for concrete skin.
Properties skinProperties = new Properties(defaultProperties);
@@ -309,14 +332,16 @@
String property = skinProperties.getProperty(propertyName);
if (null != property) {
int count = 0;
- while ( property.startsWith("&")) {
+ while (property.startsWith("&")) {
property = skinProperties
.getProperty(property.substring(1));
- if(null == property){
- throw new FacesException(Messages.getMessage(Messages.SKIN_ILLEGAL_REFERENCE,propertyName));
+ if (null == property) {
+ throw new FacesException(Messages.getMessage(
+ Messages.SKIN_ILLEGAL_REFERENCE, propertyName));
}
- if(count++>1000){
- throw new FacesException(Messages.getMessage(Messages.SKIN_CYCLIC_REFERENCE,propertyName));
+ if (count++ > 1000) {
+ throw new FacesException(Messages.getMessage(
+ Messages.SKIN_CYCLIC_REFERENCE, propertyName));
}
}
if (SkinFactory.isValueReference(property)) {
Added: trunk/framework/impl/src/main/resources/META-INF/.faces-config.xml.jsfdia
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/.faces-config.xml.jsfdia (rev 0)
+++ trunk/framework/impl/src/main/resources/META-INF/.faces-config.xml.jsfdia 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<PROCESS ENTITY="JSFProcess"/>
Modified: trunk/framework/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-08-03 19:33:52 UTC (rev 2059)
+++ trunk/framework/impl/src/main/resources/META-INF/faces-config.xml 2007-08-04 01:05:53 UTC (rev 2060)
@@ -31,6 +31,11 @@
<managed-bean-class>org.richfaces.skin.SkinBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>richSkin</managed-bean-name>
+ <managed-bean-class>org.richfaces.skin.SkinBean</managed-bean-class>
+ <managed-bean-scope>application</managed-bean-scope>
+ </managed-bean>
<managed-bean>
<managed-bean-name>ajaxContext</managed-bean-name>
<managed-bean-class>org.ajax4jsf.context.AjaxContextImpl</managed-bean-class>
Added: trunk/ui/dataFilterSlider/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/dataFilterSlider/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/dataFilterSlider/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/dataFilterSlider/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/dataTable/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/dataTable/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/dataTable/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/dataTable/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/datascroller/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/datascroller/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/datascroller/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/datascroller/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/drag-drop/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/drag-drop/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/drag-drop/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/drag-drop/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/dropdown-menu/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/dropdown-menu/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/dropdown-menu/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/dropdown-menu/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/gmap/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/gmap/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/gmap/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/gmap/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/menu-components/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/menu-components/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/menu-components/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/menu-components/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/modal-panel/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/modal-panel/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/modal-panel/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/modal-panel/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/panel/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/panel/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/panel/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/panel/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/panelbar/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/panelbar/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/panelbar/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/panelbar/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/simpleTogglePanel/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/simpleTogglePanel/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/simpleTogglePanel/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/simpleTogglePanel/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/spacer/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/spacer/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/spacer/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/spacer/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/suggestionbox/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/suggestionbox/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/suggestionbox/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/suggestionbox/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/togglePanel/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/togglePanel/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/togglePanel/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/togglePanel/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/ui/toolBar/src/main/java/META-INF/MANIFEST.MF
===================================================================
--- trunk/ui/toolBar/src/main/java/META-INF/MANIFEST.MF (rev 0)
+++ trunk/ui/toolBar/src/main/java/META-INF/MANIFEST.MF 2007-08-04 01:05:53 UTC (rev 2060)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
Property changes on: trunk/ui/toolBar/src/main/java/META-INF/MANIFEST.MF
___________________________________________________________________
Name: svn:mime-type
+ text/plain
17 years, 5 months
JBoss Rich Faces SVN: r2059 - trunk/samples.
by richfaces-svn-commits@lists.jboss.org
Author: ishabalov
Date: 2007-08-03 15:33:52 -0400 (Fri, 03 Aug 2007)
New Revision: 2059
Modified:
trunk/samples/pom.xml
Log:
Fixed tomcat 6 configuration
Modified: trunk/samples/pom.xml
===================================================================
--- trunk/samples/pom.xml 2007-08-03 17:41:23 UTC (rev 2058)
+++ trunk/samples/pom.xml 2007-08-03 19:33:52 UTC (rev 2059)
@@ -333,6 +333,18 @@
<version>1.2_04</version>
<scope>runtime</scope>
</dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>el-impl</groupId>
+ <artifactId>el-impl</artifactId>
+ <version>1.0</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</profile>
<profile>
17 years, 5 months
JBoss Rich Faces SVN: r2057 - in trunk: samples/calendar-sample/src/main/webapp/pages and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: akushunin
Date: 2007-08-03 12:39:29 -0400 (Fri, 03 Aug 2007)
New Revision: 2057
Modified:
trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
trunk/ui/calendar/src/main/config/component/calendar.xml
trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
trunk/ui/calendar/src/test/java/org/richfaces/component/CurrentDateEventTest.java
Log:
Implementing new functionality...
Modified: trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java
===================================================================
--- trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java 2007-08-03 15:59:04 UTC (rev 2056)
+++ trunk/samples/calendar-sample/src/main/java/org/richfaces/CalendarBean.java 2007-08-03 16:39:29 UTC (rev 2057)
@@ -39,11 +39,13 @@
private Locale locale;
private boolean popup;
+ private boolean readonly;
private String pattern;
private Date currentDate;
private Date selectedDate;
private String jointPoint;
private String direction;
+ private String inputType;
private boolean useCustomDayLabels;
@@ -80,8 +82,27 @@
pattern = "MMM d, yyyy";
jointPoint = "bottom-left";
direction = "bottom-right";
+ readonly=true;
+ inputType="readonly";
}
+
+ public String getInputType() {
+ return inputType;
+ }
+
+ public void setInputType(String inputType) {
+ this.inputType = inputType;
+ }
+
+ public boolean isReadonly() {
+ return readonly;
+ }
+
+ public void setReadonly(boolean readonly) {
+ this.readonly = readonly;
+ }
+
public void selectLocale(ValueChangeEvent event){
String tLocale = (String) event.getNewValue();
Modified: trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp
===================================================================
--- trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-08-03 15:59:04 UTC (rev 2056)
+++ trunk/samples/calendar-sample/src/main/webapp/pages/Calendar.jsp 2007-08-03 16:39:29 UTC (rev 2057)
@@ -39,7 +39,8 @@
currentDate="#{calendarBean.currentDate}"
jointPoint="#{calendarBean.jointPoint}"
direction="#{calendarBean.direction}"
- buttonLabel="PopUp">
+ buttonLabel="PopUp"
+ inputType="#{calendarBean.inputType}">
<f:validator validatorId="org.richfaces.CalendarValidator" />
@@ -87,7 +88,15 @@
<f:selectItem itemLabel="top-right" itemValue="top-right"/>
<f:selectItem itemLabel="top-left" itemValue="top-left"/>
<f:selectItem itemLabel="auto" itemValue="auto"/>
- </h:selectOneRadio>
+ </h:selectOneRadio>
+ <h:outputText value="InputType:" />
+ <h:selectOneRadio onchange="submit()" value="#{calendarBean.inputType}">
+ <f:selectItem itemLabel="readonly" itemValue="readonly"/>
+ <f:selectItem itemLabel="hidden" itemValue="hidden"/>
+ <f:selectItem itemLabel="editable" itemValue="editable"/>
+ </h:selectOneRadio>
+
+
<%-- <h:commandButton id="calendarPopup" type="button" value="popup" onclick="$(this.form.id+':calendar').component.doSwitch();"/>
--%> </h:panelGrid>
@@ -101,6 +110,8 @@
<h:commandButton value="Submit"/>
+
+
</h:form>
</f:view>
</body>
Modified: trunk/ui/calendar/src/main/config/component/calendar.xml
===================================================================
--- trunk/ui/calendar/src/main/config/component/calendar.xml 2007-08-03 15:59:04 UTC (rev 2056)
+++ trunk/ui/calendar/src/main/config/component/calendar.xml 2007-08-03 16:39:29 UTC (rev 2057)
@@ -151,6 +151,13 @@
<classname>java.lang.String</classname>
<description></description>
<defaultvalue>"batch"</defaultvalue>
+ </property>
+ <property>
+ <name>inputType</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue>"readonly"</defaultvalue>
</property>
+
</component>
</components>
Modified: trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java
===================================================================
--- trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-08-03 15:59:04 UTC (rev 2056)
+++ trunk/ui/calendar/src/main/java/org/richfaces/component/UICalendar.java 2007-08-03 16:39:29 UTC (rev 2057)
@@ -128,7 +128,13 @@
public abstract String getToolTipMode();
public abstract void setToolTipMode(String toolTipMode);
+
+ public abstract String getInputType();
+ public abstract void setInputType(String inputType);
+
+
+
// currentDate processing -------------------------------------------------
public Calendar getCalendar() {
@@ -254,12 +260,14 @@
calendar.clear();
calendar.set(Calendar.DATE, 1);
int idx = currentDateString.indexOf('/');
+ if (idx != -1){
calendar.set(Calendar.MONTH, Integer.parseInt(currentDateString
.substring(0, idx)) - 1);
calendar.set(Calendar.YEAR, Integer.parseInt(currentDateString
.substring(idx + 1)));
return calendar.getTime();
+ }else {return null;}
}
Modified: trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx
===================================================================
--- trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-08-03 15:59:04 UTC (rev 2056)
+++ trunk/ui/calendar/src/main/templates/org/richfaces/htmlCalendar.jspx 2007-08-03 16:39:29 UTC (rev 2057)
@@ -60,7 +60,22 @@
<![CDATA[
boolean popup = getUtils().isBooleanAttribute(component, "popup");
if (popup) {
- addPopupToAjaxRendered(context, component);]]>
+ addPopupToAjaxRendered(context, component);
+ Boolean readonly = Boolean.FALSE;
+ String hidden = "text";
+ String inputType = component.getAttributes().get("inputType").toString();
+ if(inputType.equals("readonly")){
+ readonly=Boolean.TRUE;
+ }
+ else{
+ if (inputType.equals("hidden")){
+ hidden = inputType;
+ }
+ }
+ variables.setVariable("readonly",readonly);
+ variables.setVariable("hidden",hidden);
+ ]]>
+
</jsp:scriptlet>
<span
@@ -70,8 +85,8 @@
id="#{clientId}InputDate"
name="#{clientId}InputDate"
value="#{this:getInputValue(context,component)}"
- type="text"
- readonly="#{component.attributes['readonly']}"
+ type="#{hidden}"
+ readonly="#{readonly}"
disabled="#{component.attributes['disabled']}"
accesskey="#{component.attributes['accesskey']}"
maxlength="#{component.attributes['maxlength']}"
Modified: trunk/ui/calendar/src/test/java/org/richfaces/component/CurrentDateEventTest.java
===================================================================
--- trunk/ui/calendar/src/test/java/org/richfaces/component/CurrentDateEventTest.java 2007-08-03 15:59:04 UTC (rev 2056)
+++ trunk/ui/calendar/src/test/java/org/richfaces/component/CurrentDateEventTest.java 2007-08-03 16:39:29 UTC (rev 2057)
@@ -35,7 +35,7 @@
private CurrentDateChangeEvent event2;
private CurrentDateChangeEvent event4;
private AjaxEvent event3;
- private UICalendar calendar;
+ private UICalendar calendar;
private Calendar cal;
/**
@@ -56,7 +56,7 @@
calendar = (UICalendar) application.createComponent(UICalendar.COMPONENT_TYPE);;
event1 = new CurrentDateChangeEvent (calendar, "11/2001");
cal = Calendar.getInstance();
- cal.set(2001, 10, 9);
+ cal.set(2001, 0, 9);
event2 = new CurrentDateChangeEvent (calendar, cal.getTime());
event4 = new CurrentDateChangeEvent (calendar, "");
event3 = new AjaxEvent(calendar);
@@ -78,9 +78,11 @@
}
public void testBrodcastEvent() throws Exception{
+ calendar.broadcast(event4);
calendar.broadcast(event1);
calendar.broadcast(event3);
- calendar.broadcast(event4);
+ System.out.println(calendar.getCurrentDate().toString());
+
// calendar.broadcast(event2);
}
17 years, 5 months