Author: nbelaevski
Date: 2011-03-11 07:39:15 -0500 (Fri, 11 Mar 2011)
New Revision: 22160
Modified:
branches/4.0.X/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
branches/4.0.X/examples/iteration-demo/src/main/webapp/tree.xhtml
branches/4.0.X/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
Log:
https://issues.jboss.org/browse/RF-9718
Reviewed by Ilya
Modified:
branches/4.0.X/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java
===================================================================
---
branches/4.0.X/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2011-03-11
11:56:56 UTC (rev 22159)
+++
branches/4.0.X/examples/iteration-demo/src/main/java/org/richfaces/demo/TreeBean.java 2011-03-11
12:39:15 UTC (rev 22160)
@@ -52,7 +52,9 @@
import org.richfaces.event.TreeToggleListener;
import org.richfaces.log.LogFactory;
import org.richfaces.log.Logger;
+import org.richfaces.model.SwingTreeNodeDataModelImpl;
import org.richfaces.model.SwingTreeNodeImpl;
+import org.richfaces.model.TreeDataModel;
import org.richfaces.model.TreeNodeImpl;
/**
@@ -112,6 +114,8 @@
private List<TreeNode> lazyRootNodes;
+ private TreeDataModel<?> treeDataModel;
+
private SwitchType toggleType = SwitchType.DEFAULT;
private SwitchType selectionType = SwitchType.client;
@@ -187,6 +191,8 @@
rootNodes = parser.getRootNodes();
lazyRootNodes = createLazyNodes(rootNodes);
classicTreeNode = createRootClassicNode(rootNodes);
+ treeDataModel = new SwingTreeNodeDataModelImpl();
+ treeDataModel.setWrappedData(rootNodes);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
@@ -307,4 +313,8 @@
return INTEGER_SEQUENCE_KEY_CONVERTER;
}
+ public TreeDataModel<?> getTreeDataModel() {
+ return treeDataModel;
+ }
+
}
Modified: branches/4.0.X/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- branches/4.0.X/examples/iteration-demo/src/main/webapp/tree.xhtml 2011-03-11 11:56:56
UTC (rev 22159)
+++ branches/4.0.X/examples/iteration-demo/src/main/webapp/tree.xhtml 2011-03-11 12:39:15
UTC (rev 22160)
@@ -131,8 +131,12 @@
</it:treeNode>
</it:tree>
+ <h:commandLink value="Re-render">
+ <f:ajax render=":form:tree" execute="@all" />
+ </h:commandLink>
+
org.richfaces.model.TreeNode support:
- <it:tree value="#{treeBean.classicTreeNode}" var="node"
+ <it:tree id="treeNodeSupport"
value="#{treeBean.classicTreeNode}" var="node"
selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}"
rowKeyConverter="#{treeBean.integerSequenceKeyConveter}">
<it:treeNode>
@@ -143,9 +147,17 @@
</it:treeNode>
</it:tree>
- <h:commandLink value="Re-render">
- <f:ajax render=":form:tree" execute="@all" />
- </h:commandLink>
+ org.richfaces.model.TreeDataModel support:
+ <it:tree id="treeDataModelSupport"
value="#{treeBean.treeDataModel}" var="node"
+ selectionType="#{treeBean.selectionType}"
toggleType="#{treeBean.toggleType}"
+ rowKeyConverter="#{treeBean.integerSequenceKeyConveter}">
+ <it:treeNode>
+ #{node.data} -
+ <h:commandLink value="link"
action="#{treeBean.clickNode}">
+ <f:ajax render=":messages" />
+ </h:commandLink>
+ </it:treeNode>
+ </it:tree>
Tree with customized look:
<it:tree id="customizedTree" var="node"
value="#{treeBean.rootNodes}"
Modified:
branches/4.0.X/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
---
branches/4.0.X/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2011-03-11
11:56:56 UTC (rev 22159)
+++
branches/4.0.X/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2011-03-11
12:39:15 UTC (rev 22160)
@@ -478,6 +478,14 @@
} else if (value instanceof TreeNode) {
dataModel = new ClassicTreeNodeDataModelImpl();
dataModel.setWrappedData(value);
+ } else if (value instanceof TreeDataModel<?>) {
+ if (value instanceof ExtendedDataModel<?>) {
+ dataModel = (ExtendedDataModel<?>) value;
+ } else {
+ throw new IllegalArgumentException(
+ MessageFormat.format("TreeDataModel implementation {0} is not a
subclass of ExtendedDataModel",
+ value.getClass().getName()));
+ }
} else {
dataModel = new SwingTreeNodeDataModelImpl();
dataModel.setWrappedData(value);