Author: bleathem
Date: 2011-11-07 16:05:27 -0500 (Mon, 07 Nov 2011)
New Revision: 22899
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-Basic_usage_impl.java
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-Basic_usage.js
Log:
RFPL-1433: Added a TreeNodeImpl extension to the basic tree example
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml
===================================================================
---
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml 2011-11-07
20:03:24 UTC (rev 22898)
+++
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml 2011-11-07
21:05:27 UTC (rev 22899)
@@ -27,8 +27,14 @@
This example demonstrates basic usage of the
<sgmltag><rich:tree></sgmltag> component using an
<interfacename>org.richfaces.model.TreeNode</interfacename> data model.
</para>
<para>
- The data model is constructed as follows:
+ First extend the
<classname>org.richfaces.model.TreeNodeImpl</classname> and add the data
fields you require, with appropriate accessor methods, as in:
</para>
+ <para>
+ <programlisting language="Java"
role="JAVA"><xi:include parse="text"
href="extras/exam-Component_Reference-richtree-Basic_usage_impl.java"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </para>
+ <para>
+ Then, the data model is constructed as follows:
+ </para>
<programlisting language="Java" role="JAVA"><xi:include
parse="text"
href="extras/exam-Component_Reference-richtree-Basic_usage.js"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
<para>
The tree then accesses the nodes of the model using the
<literal>station</literal> variable:
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-Basic_usage.js
===================================================================
---
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-Basic_usage.js 2011-11-07
20:03:24 UTC (rev 22898)
+++
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-Basic_usage.js 2011-11-07
21:05:27 UTC (rev 22899)
@@ -1,5 +1,5 @@
-private TreeNodeImpl<String> stationRoot = new TreeNodeImpl<String>();
-private TreeNodeImpl<String> stationNodes = new TreeNodeImpl<String>();
+private DataHolderTreeNodeImpl stationRoot = new DataHolderTreeNodeImpl();
+private DataHolderTreeNodeImpl stationNodes = new DataHolderTreeNodeImpl();
private String[] kickRadioFeed = { "Hall & Oates - Kiss On My List",
"David Bowie - Let's Dance",
"Lyn Collins - Think (About It)",
@@ -9,7 +9,6 @@
stationRoot.setData("KickRadio");
stationNodes.addChild(0, stationRoot);
for (int i = 0; i < kickRadioFeed.length; i++){
- TreeNodeImpl<String> child = new TreeNodeImpl<String>();
- child.setData(kickRadioFeed[i]);
+ DataHolderTreeNodeImpl child = new DataHolderTreeNodeImpl(true, kickRadioFeed[i]);
stationRoot.addChild(i, child);
}
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-Basic_usage_impl.java
===================================================================
---
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-Basic_usage_impl.java
(rev 0)
+++
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-Basic_usage_impl.java 2011-11-07
21:05:27 UTC (rev 22899)
@@ -0,0 +1,19 @@
+import org.richfaces.model.TreeNodeImpl;
+
+public class DataHolderTreeNodeImpl extends TreeNodeImpl {
+ private Object data;
+
+ public DataHolderTreeNodeImpl(boolean leaf, Object data) {
+ super(leaf);
+ this.data = data;
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " >> " + data;
+ }
+}
\ No newline at end of file