Adobe COLDFUSION 9 Manual page 841

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
<cfcomponent>
<cffunction name="getNodes" returnType="array" output="no" access="remote">
<cfargument name="nodeitemid" required="true">
<cfargument name="nodeitempath" required="true">
<!--- The initial value of the top level is the empty string. --->
<cfif nodeitemid IS "">
<cfset nodeitemid =0>
</cfif>
<!--- Create an array with one element defining the child node. --->
<cfset nodeArray = ArrayNew(1)>
<cfset element1 = StructNew()>
<cfset element1.value = nodeitemid + 1>
<cfset element1.display = "Node #nodeitemid#">
<cfset nodeArray[1] = element1>
<cfreturn nodeArray>
</cffunction>
</cfcomponent>
Handling leaf nodes
Code that returns the information for leaf nodes of the trees must always set the LEAFNODE structure field to
This prevents the tree from displaying a + expansion indicator in the tree leaf node tree entries and from attempting
to expand the node. The following example shows how you use the LEAFNODE field.
Example 2: a more complex tree with leaf node handling
The following tree uses the cfartgallery database to populate a tree where the top level is the art medium, the second
level is the artist, and the leaf nodes are individual works of art. When the user clicks an artwork, the application shows
the art image.
This example shows how to generate return values that are specific to the level in the tree and the parent value. It also
shows the use of the LEAFNODE return structure element.
In this application, the CFC return structure keys are specified in lowercase letters, and ColdFusion automatically
converts them to uppercase. Notice that the database contains entries only for the painting, sculpture, and
photography categories, so just those top-level tree nodes have child nodes.
The following example shows the main application page:
Last updated 8/5/2010
836
.
true

Advertisement

Table of Contents
loading

Table of Contents