Author: nbelaevski
Date: 2009-03-18 16:13:06 -0400 (Wed, 18 Mar 2009)
New Revision: 13016
Added:
trunk/samples/treeModelDemo/src/main/java/org/richfaces/rf4351/
trunk/samples/treeModelDemo/src/main/java/org/richfaces/rf4351/Bean.java
trunk/samples/treeModelDemo/src/main/webapp/pages/rf-4351.jsp
Modified:
trunk/samples/treeModelDemo/src/main/java/org/richfaces/TreeModelBean.java
trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
Log:
https://jira.jboss.org/jira/browse/RF-4351
Modified: trunk/samples/treeModelDemo/src/main/java/org/richfaces/TreeModelBean.java
===================================================================
--- trunk/samples/treeModelDemo/src/main/java/org/richfaces/TreeModelBean.java 2009-03-18
20:12:27 UTC (rev 13015)
+++ trunk/samples/treeModelDemo/src/main/java/org/richfaces/TreeModelBean.java 2009-03-18
20:13:06 UTC (rev 13016)
@@ -3,10 +3,14 @@
*/
package org.richfaces;
+import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.richfaces.component.UITree;
+import org.richfaces.component.html.HtmlRecursiveTreeNodesAdaptor;
import org.richfaces.model.SimpleRecursiveNode;
+import org.richfaces.model.StackingTreeModel;
/**
* @author Nick Belaevski
@@ -15,12 +19,44 @@
*
*/
public class TreeModelBean {
+
+ private HtmlRecursiveTreeNodesAdaptor binding = new MyHtmlRecursiveTreeNodesAdaptor();
+
+ public HtmlRecursiveTreeNodesAdaptor getBinding() {
+ return binding;
+ }
+
+ public void setBinding(HtmlRecursiveTreeNodesAdaptor binding) {
+ this.binding = binding;
+ }
+
public Boolean adviseNodeOpened(UITree tree) {
return Boolean.TRUE;
}
private SimpleRecursiveNode simpleRecursiveNode;
+ public static class MyHtmlRecursiveTreeNodesAdaptor extends
HtmlRecursiveTreeNodesAdaptor {
+ @Override
+ public StackingTreeModel getStackingModel() {
+ StackingTreeModel stackingModel = super.getStackingModel();
+
+// Iterator iterator = stackingModel.getModelsIterator();
+// List<StackingTreeModel> list = new ArrayList<StackingTreeModel>();
+// while (iterator.hasNext()) {
+// list.add((StackingTreeModel) iterator.next());
+// if (iterator.hasNext()) {
+// iterator.remove();
+// }
+// }
+//
+// for (StackingTreeModel stackingTreeModel : list) {
+// stackingModel.addStackingModel(stackingTreeModel);
+// }
+ return stackingModel;
+ }
+ };
+
public TreeModelBean() {
simpleRecursiveNode = new SimpleRecursiveNode(null, null);
for (int i = 0; i < 5; i++) {
Added: trunk/samples/treeModelDemo/src/main/java/org/richfaces/rf4351/Bean.java
===================================================================
--- trunk/samples/treeModelDemo/src/main/java/org/richfaces/rf4351/Bean.java
(rev 0)
+++ trunk/samples/treeModelDemo/src/main/java/org/richfaces/rf4351/Bean.java 2009-03-18
20:13:06 UTC (rev 13016)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.rf4351;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ */
+
+public class Bean {
+
+ private List<String[]> list;
+
+ public List<String[]> getList() {
+ if (list == null) {
+ list = new ArrayList<String[]>();
+ for (int i = 0; i < 5; i++) {
+ String[] s = new String[5];
+ for (int j = 0; j < s.length; j++) {
+ s[j] = UUID.randomUUID().toString();
+ }
+
+ list.add(s);
+ }
+ }
+
+ return list;
+ }
+}
Modified: trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml 2009-03-18
20:12:27 UTC (rev 13015)
+++ trunk/samples/treeModelDemo/src/main/webapp/WEB-INF/faces-config.xml 2009-03-18
20:13:06 UTC (rev 13016)
@@ -13,4 +13,9 @@
<managed-bean-class>org.richfaces.Loader</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>rf4351Bean</managed-bean-name>
+ <managed-bean-class>org.richfaces.rf4351.Bean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
</faces-config>
Modified: trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2009-03-18 20:12:27 UTC
(rev 13015)
+++ trunk/samples/treeModelDemo/src/main/webapp/pages/index.jsp 2009-03-18 20:13:06 UTC
(rev 13016)
@@ -63,7 +63,7 @@
</model:treeNodesAdaptor>
<model:recursiveTreeNodesAdaptor id="dir" var="dir"
- roots="#{project.dirs}" nodes="#{dir.directories}">
+ roots="#{project.dirs}" nodes="#{dir.directories}"
binding="#{treeModelBean.binding}">
<tree:treeNode>
<a4j:commandLink action="#{dir.click}"
ajaxSingle="true" value="Immediate " /><br />
<h:commandLink action="#{dir.click}" value="Directory:
#{dir.name}" />
Added: trunk/samples/treeModelDemo/src/main/webapp/pages/rf-4351.jsp
===================================================================
--- trunk/samples/treeModelDemo/src/main/webapp/pages/rf-4351.jsp
(rev 0)
+++ trunk/samples/treeModelDemo/src/main/webapp/pages/rf-4351.jsp 2009-03-18 20:13:06 UTC
(rev 13016)
@@ -0,0 +1,38 @@
+<%@ page pageEncoding="UTF-8" contentType="text/html;
charset=UTF-8" %>
+
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+<%@ 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://labs.jboss.com/jbossrichfaces/ui/drag-drop"
prefix="dnd" %>
+<%@ taglib
uri="http://richfaces.org/a4j" prefix="a4j" %>
+
+<html>
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:messages />
+ </a4j:outputPanel>
+
+ <tree:tree switchType="ajax" id="tree"
rowKeyConverter="org.richfaces.TreeAdaptorIntegerRowKeyConverter">
+ <model:treeNodesAdaptor nodes="#{rf4351Bean.list}"
var="listElement">
+ <tree:treeNode ajaxSingle="true">
+ <h:outputText value="Node" />
+ </tree:treeNode>
+ <model:treeNodesAdaptor nodes="#{listElement}" var="s">
+ <tree:treeNode ajaxSingle="true">
+ <h:outputText value="#{s}" />
+ </tree:treeNode>
+ </model:treeNodesAdaptor>
+ </model:treeNodesAdaptor>
+
+ </tree:tree>
+ </h:form>
+ </f:view>
+ </body>
+</html>