Author: nbelaevski
Date: 2008-03-27 22:59:48 -0400 (Thu, 27 Mar 2008)
New Revision: 7343
Modified:
trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/Directory.java
trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
Log:
http://jira.jboss.com/jira/browse/RF-2812
Modified: trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/Directory.java
===================================================================
---
trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/Directory.java 2008-03-28
02:59:42 UTC (rev 7342)
+++
trunk/samples/treeModelDemo/src/main/java/org/richfaces/model/Directory.java 2008-03-28
02:59:48 UTC (rev 7343)
@@ -4,7 +4,9 @@
package org.richfaces.model;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
/**
* @author Nick Belaevski
@@ -13,29 +15,88 @@
*
*/
public class Directory extends Entry {
- private List directories = new ArrayList();
- private List files = new ArrayList();;
- public List getDirectories() {
- return directories;
- }
+
+ private Map directories = new LinkedHashMap();
+
+ public void addDir(Directory directory) {
+ this.directories.put(new StringKey(directory.getName()), directory);
+ directory.setParent(this);
+ }
+
+ public Map getDirectories() {
+ return directories;
+ }
+
+ public void setDirectories(Map directories) {
+ this.directories = directories;
+ }
+
+ public static class StringKey {
+ private String s;
+
+ public StringKey(String s) {
+ super();
+ this.s = s;
+ }
+
+ @Override
+ public String toString() {
+ return s;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((s == null) ? 0 : s.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ StringKey other = (StringKey) obj;
+ if (s == null) {
+ if (other.s != null)
+ return false;
+ } else if (!s.equals(other.s))
+ return false;
+ return true;
+ }
+
+
+ }
- public void setDirectories(List directories) {
- this.directories = directories;
- }
+// private List directories = new ArrayList();
+//
+// public List getDirectories() {
+// return directories;
+// }
+//
+// public void setDirectories(List directories) {
+// this.directories = directories;
+// }
+//
+// public void addDir(Directory directory) {
+// this.directories.add(directory);
+// directory.setParent(this);
+// }
+ private List files = new ArrayList();;
+
public List getFiles() {
- return files;
+ return files;
}
public void setFiles(List files) {
- this.files = files;
+ this.files = files;
}
-
- public void addDir(Directory directory) {
- this.directories.add(directory);
- directory.setParent(this);
- }
public void addFile(File file) {
this.files.add(file);
Modified: trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml 2008-03-28
02:59:42 UTC (rev 7342)
+++ trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml 2008-03-28
02:59:48 UTC (rev 7343)
@@ -4,6 +4,10 @@
<faces-config>
<managed-bean>
+ <managed-bean-name>tree</managed-bean-name>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>treeModelBean</managed-bean-name>
<managed-bean-class>org.richfaces.TreeModelBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
Modified: trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2008-03-28 02:59:42 UTC
(rev 7342)
+++ trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2008-03-28 02:59:48 UTC
(rev 7343)
@@ -3,6 +3,7 @@
<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/treeModel"
prefix="model" %>
<%@ taglib
uri="http://labs.jboss.com/jbossrichfaces/ui/tree"
prefix="tree" %>
+<%@ taglib
uri="http://richfaces.org/a4j" prefix="a4j" %>
<html>
<head>
@@ -11,24 +12,38 @@
<body>
<f:view>
<h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages />
+ </a4j:outputPanel>
+
+ <h:inputText required="true" value="val"/>
+
<tree:tree adviseNodeOpened="#{treeModelBean.adviseNodeOpened}"
switchType="client">
<model:treeNodesAdaptor id="project"
nodes="#{loaderBean.projects}" var="project">
<tree:treeNode>
+ <a4j:commandLink action="#{project.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{project.click}" value="Project:
#{project.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="srcDir" var="srcDir"
nodes="#{project.srcDirs}">
<tree:treeNode>
+ <a4j:commandLink action="#{srcDir.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{srcDir.click}" value="Source
directory: #{srcDir.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="pkg" var="pkg"
nodes="#{srcDir.packages}">
<tree:treeNode>
+ <a4j:commandLink action="#{pkg.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{pkg.click}" value="Package:
#{pkg.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="class" var="class"
nodes="#{pkg.classes}">
<tree:treeNode>
+ <a4j:commandLink action="#{class.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{class.click}" value="Class:
#{class.name}" />
</tree:treeNode>
</model:treeNodesAdaptor>
@@ -36,11 +51,15 @@
<model:treeNodesAdaptor id="pkg1" var="pkg"
nodes="#{srcDir.packages}">
<tree:treeNode>
+ <a4j:commandLink action="#{pkg.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{pkg.click}" value="Package1:
#{pkg.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="class1" var="class"
nodes="#{pkg.classes}">
<tree:treeNode>
+ <a4j:commandLink action="#{class.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{class.click}" value="Class1:
#{class.name}" />
</tree:treeNode>
</model:treeNodesAdaptor>
@@ -50,17 +69,23 @@
<model:recursiveTreeNodesAdaptor id="dir" var="dir"
roots="#{project.dirs}" nodes="#{dir.directories}">
<tree:treeNode>
+ <a4j:commandLink action="#{dir.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{dir.click}" value="Directory:
#{dir.name}" />
</tree:treeNode>
<model:treeNodesAdaptor id="file" var="file"
nodes="#{dir.files}">
<tree:treeNode>
+ <a4j:commandLink action="#{file.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{file.click}" value="File:
#{file.name}" />
</tree:treeNode>
</model:treeNodesAdaptor>
<model:treeNodesAdaptor id="file1" var="file"
nodes="#{dir.files}">
<tree:treeNode>
+ <a4j:commandLink action="#{file.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{file.click}" value="File1:
#{file.name}" />
</tree:treeNode>
</model:treeNodesAdaptor>
@@ -71,6 +96,8 @@
includedNode="#{archiveEntry.class.simpleName ==
'ArchiveEntry'}">
<tree:treeNode id="archiveEntryNode">
+ <a4j:commandLink action="#{archiveEntry.click}"
ajaxSingle="true" value="Immediate " />
+ <br />
<h:commandLink action="#{archiveEntry.click}" value="Archive
entry: #{archiveEntry.name}" />
</tree:treeNode>