Author: SeanRogers
Date: 2011-02-24 00:30:15 -0500 (Thu, 24 Feb 2011)
New Revision: 21908
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemBean.java
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemNode.java
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/exam-Component_Reference-richtreeModelRecursiveAdaptor-Basic_usage.png
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-Validation.xml
Log:
Updated trees declarative models documentation RFPL-991
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-02-24
01:35:22 UTC (rev 21907)
+++
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml 2011-02-24
05:30:15 UTC (rev 21908)
@@ -425,23 +425,26 @@
<section id="sect-Component_Reference-Trees-Tree_adaptors">
<title>Tree adaptors</title>
<para>
- Use a tree adaptor to create a tree and populate it with data from a defined data
model.
+ Use a tree adaptor to populate a tree model declaratively from a non-hierarchical
model, such as a list or a map.
</para>
<section
id="sect-Component_Reference-Tree_adaptors-richtreeModelAdaptor">
<title><sgmltag><rich:treeModelAdaptor></sgmltag></title>
<para>
- The <sgmltag><rich:treeModelAdaptor></sgmltag> component
takes a defined data model and uses it to populate an associated
<sgmltag><rich:tree></sgmltag> component.
+ The <sgmltag><rich:treeModelAdaptor></sgmltag> component
takes an object which implements the <interfacename>Map</interfacename> or
<interfacename>Iterable</interfacename> interfaces. It adds all the object
entries to the parent node as child nodes.
</para>
<section
id="sect-Component_Reference-richtreeModelAdaptor-Basic_usage">
<title>Basic usage</title>
<para>
- The <sgmltag><rich:treeModelAdaptor></sgmltag> component
is added as a nested child component to the
<sgmltag><rich:tree></sgmltag> component it will populate.
+ The <sgmltag><rich:treeModelAdaptor></sgmltag> component
is added as a nested child component to a
<sgmltag><rich:tree></sgmltag> component, or to another tree
adaptor component.
</para>
<para>
- The <sgmltag><rich:treeModelAdaptor></sgmltag> component
requires the <varname>nodes</varname> attribute for basic usage. The
<varname>nodes</varname> attribute defines a collection of elements to iterate
through for populating the tree.
+ The <sgmltag><rich:treeModelAdaptor></sgmltag> component
requires the <varname>nodes</varname> attribute for basic usage. The
<varname>nodes</varname> attribute defines a collection of elements to iterate
through for populating the nodes.
</para>
+ <para>
+ Define the appearance of each node added by the adaptor with a child
<sgmltag><rich:treeNode></sgmltag> component. Refer to <xref
linkend="sect-Component_Reference-Trees-richtreeNode" /> for details on the
<sgmltag><rich:treeNode></sgmltag> component.
+ </para>
</section>
<section
id="sect-Component_Reference-richtreeModelAdaptor-Multiple_levels">
@@ -450,12 +453,15 @@
<sgmltag><rich:treeModelAdaptor></sgmltag> components can
further be nested in other
<sgmltag><rich:treeModelAdaptor></sgmltag> components to
subsequently populate lower levels of the tree.
</para>
<para>
- Use the <varname>var</varname> attribute to access the current
collection element at each level. <xref
linkend="exam-Component_Reference-richtreeModelAdaptor-Nested_richtreeModelAdaptor_components"
/> demonstrates a series of nested
<sgmltag><rich:treeModelAdaptor></sgmltag> components, each
using the parent's <varname>var</varname> attribute to reference the
current element.
+ To access the current element at each iteration, use the
<varname>var</varname> attribute of either the parent
<sgmltag><rich:tree></sgmltag> component or the
<sgmltag><rich:treeModelAdaptor></sgmltag> component itself.
<xref
linkend="exam-Component_Reference-richtreeModelAdaptor-Nested_richtreeModelAdaptor_components"
/> demonstrates a series of nested
<sgmltag><rich:treeModelAdaptor></sgmltag> components, each
using the parent's <varname>var</varname> attribute to reference the
current element.
</para>
<example
id="exam-Component_Reference-richtreeModelAdaptor-Nested_richtreeModelAdaptor_components">
<title><sgmltag>Nested <rich:treeModelAdaptor>
components</sgmltag></title>
<programlisting language="XML" role="XML"><xi:include
parse="text"
href="extras/exam-Component_Reference-richtreeModelAdaptor-Nested_richtreeModelAdaptor_components.xml_sample"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</example>
+ <para>
+ Each <sgmltag><rich:treeModelAdaptor></sgmltag> component
is mapped to a list of objects. During the iteration, the corresponding object properties
are used to define the node labels and actions, and are in turn used for iterating through
nested lists.
+ </para>
</section>
<section
id="sect-Component_Reference-richtreeModelAdaptor-Reference_data">
@@ -488,7 +494,7 @@
<section
id="sect-Component_Reference-Tree_adaptors-richtreeModelRecursiveAdaptor">
<title><sgmltag><rich:treeModelRecursiveAdaptor></sgmltag></title>
<para>
- The <sgmltag><rich:treeModelRecursiveAdaptor></sgmltag>
component recursively populates a tree with hierarchical nodes, such as for a file system
with multiple levels of directories and files.
+ The <sgmltag><rich:treeModelRecursiveAdaptor></sgmltag>
component iterates through recursive collections in order to populate a tree with
hierarchical nodes, such as for a file system with multiple levels of directories and
files.
</para>
<section
id="sect-Component_Reference-richtreeModelRecursiveAdaptor-Basic_usage">
@@ -505,6 +511,30 @@
<example
id="exam-Component_Reference-richtreeModelRecursiveAdaptor-Basic_usage">
<title>Basic usage</title>
<programlisting language="XML" role="XML"><xi:include
parse="text"
href="extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-Basic_usage.xml_sample"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <para>
+ The <sgmltag><rich:treeModelRecursiveAdaptor></sgmltag>
component references the <classname>FileSystemBean</classname> class as the
source for the data.
+ </para>
+ <programlisting language="Java" role="JAVA"><xi:include
parse="text"
href="extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemBean.java"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <para>
+ The <classname>FileSystemBean</classname> class in turn uses the
<classname>FileSystemNode</classname> class to recursively iterate through the
collection.
+ </para>
+ <programlisting language="Java" role="JAVA"><xi:include
parse="text"
href="extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemNode.java"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <para>
+ The <function>getDirectories()</function> function is used recursively
until the object has the collection of children. The model adaptor calls the
<function>getFiles()</function> function at each level in order to add the
file nodes.
+ </para>
+ <para>
+ The resulting tree hierarchically lists the directories and files in the
collection.
+ </para>
+ <mediaobject>
+ <imageobject>
+ <imagedata
fileref="images/exam-Component_Reference-richtreeModelRecursiveAdaptor-Basic_usage.png"
format="PNG" />
+ </imageobject>
+ <textobject>
+ <para>
+ A hierarchical tree detailing a file system.
+ </para>
+ </textobject>
+ </mediaobject>
</example>
</section>
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Validation.xml
===================================================================
---
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Validation.xml 2011-02-24
01:35:22 UTC (rev 21907)
+++
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Validation.xml 2011-02-24
05:30:15 UTC (rev 21908)
@@ -11,7 +11,7 @@
</para>
<example
id="exam-Component_Reference-Validation-JSR-303_validation_annotations">
<title>JSR-303 validation annotations</title>
- <programlisting language="XML" role="XML"><xi:include
parse="text"
href="extras/exam-Component_Reference-Validation-JSR-303_validation_annotations.js"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <programlisting language="Java" role="JAVA"><xi:include
parse="text"
href="extras/exam-Component_Reference-Validation-JSR-303_validation_annotations.js"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</example>
<note>
<title>Requirements</title>
@@ -152,7 +152,7 @@
<para>
The input controls validate against the following bean:
</para>
- <programlisting language="XML" role="XML"><xi:include
parse="text"
href="extras/exam-Component_Reference-richgraphValidator-Basic_usage.js"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <programlisting language="Java" role="JAVA"><xi:include
parse="text"
href="extras/exam-Component_Reference-richgraphValidator-Basic_usage.js"
xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
<para>
When validation occurs, the whole object is validated against the annotation
contstraints. The <varname>@AssertTrue</varname> annotation relies on the
<methodname>isPasswordsEqual()</methodname> function to check whether the two
entered passwords are equal.
</para>
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemBean.java
===================================================================
---
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemBean.java
(rev 0)
+++
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemBean.java 2011-02-24
05:30:15 UTC (rev 21908)
@@ -0,0 +1,14 @@
+@ManagedBean
+@RequestScoped
+public class FileSystemBean {
+ private static final String SRC_PATH = "/WEB-INF";
+
+ private List<FileSystemNode> srcRoots;
+
+ public synchronized List<FileSystemNode> getSourceRoots() {
+ if (srcRoots == null) {
+ srcRoots = new FileSystemNode(SRC_PATH).getDirectories();
+ }
+ return srcRoots;
+ }
+}
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemNode.java
===================================================================
---
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemNode.java
(rev 0)
+++
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtreeModelRecursiveAdaptor-FileSystemNode.java 2011-02-24
05:30:15 UTC (rev 21908)
@@ -0,0 +1,30 @@
+public class FileSystemNode {
+ ...
+ public synchronized List<FileSystemNode> getDirectories() {
+ if (directories == null) {
+ directories = Lists.newArrayList();
+ Iterables.addAll(directories, transform(filter(getResourcePaths(),
containsPattern("/$")), FACTORY));
+ }
+ return directories;
+ }
+
+ public synchronized List<String> getFiles() {
+ if (files == null) {
+ files = new ArrayList<String>();
+ Iterables.addAll(files, transform(filter(getResourcePaths(),
not(containsPattern("/$"))), TO_SHORT_PATH));
+ }
+ return files;
+ }
+
+ private Iterable<String> getResourcePaths() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ Set<String> resourcePaths = externalContext.getResourcePaths(this.path);
+
+ if (resourcePaths == null) {
+ resourcePaths = Collections.emptySet();
+ }
+ return resourcePaths;
+ }
+ ...
+}
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/exam-Component_Reference-richtreeModelRecursiveAdaptor-Basic_usage.png
===================================================================
(Binary files differ)
Property changes on:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/exam-Component_Reference-richtreeModelRecursiveAdaptor-Basic_usage.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream