Thanks for the tips Sean, Raymond, et al....

I had tried using the VAR bit before, but the code choked.  I didn't even
think of doing it in CFSET tags.  (And, I learned that a CFTRY tag is
interpreted as executable code.)  The function is working now.

As for my use of the CFPROPERTY tags, I know they are kinda useless in the
manner I'm using them, EXCEPT for documentation.  If you pull up the CFC in
a browser directly (i.e. http://myserver/mydir/mycfc.cfc), then you get a
very nicely formated page documenting everything there is to know about the
component.  If you don't use the CFPROPERTY tag, then the properties section
is empty.  We are intending to print these screens to document our classes,
so having the properties listed is an added bonus.  Also, some of our
components will likely become web services in the near future - we're still
getting the core code into place so we can proceed with the presentation
layer.

Thanks for the input on recursion, and some tips on CFProperty - on which I
have not been able to find any great details.

Shawn

-----Original Message-----
From: Sean A Corfield [mailto:[EMAIL PROTECTED]
Sent: Monday, May 26, 2003 8:07 PM
To: CF-Talk
Subject: Re: Help with CFC and recursion?


On Monday, May 26, 2003, at 17:41 US/Pacific, Shawn Grover wrote:
> I've tried a number of combinations for the code, and always seem to 
> get a
> similar result.

You need to use 'var' to declare your variables local - otherwise they 
are just instance variables and get overwritten by each recursive call.

> <cfcomponent>
>       <cfproperty name="Category" type="caa.intranet.cfc.data.category">

Why bother with this if it isn't a Web Service? cfproperty has no 
useful purpose except for type-checking Web Service returns.

>       <cfscript>
>               this.Category = createObject("component",
> "caa.intranet.cfc.data.category");
>               this.Category.Clear();
>               this.List = this.Category.List();       
>       </cfscript>
>
>       <cffunction name="BuildTree" access="public" returntype="string" >
>               <cfset qRoot = getChildren(0)>

        <cfset var qRoot = getChildren(0)>

>               <cfset sTree = "">

        <cfset var sTree = "">

>               <cfloop query="qRoot">
>                       <cfset sTree = sTree & AddNode(qRoot.Category_ID,
> qRoot.Category_Name)>
>               </cfloop>
>                                                       
>               <cfreturn sTree>
>       </cffunction>
>       
>       <cffunction name="AddNode" access="private" returntype="string"
> output="no">
>               <cfargument name="CategoryID" type="numeric" required="Yes">
>               <cfargument name="CategoryName" type="string"
> required="Yes">

        <cfset var sChild = "">
        <cfset var qChildren = "">

>               <cfscript>
>                       sChild = "[#JSStringFormat(Arguments.CategoryName)#,
> 'javascript:node_clicked(#Arguments.CategoryID#);', null";
>                       
>                       qChildren = getChildren(Arguments.CategoryID);
>                       for (x=1; x lte qChildren.RecordCount; x=x+1) {
>                               sChild = sChild &
> AddNode(qChildren.Category_ID[x], qChildren.Category_Name[x]);
>                       }
>                               
>                       sChild = sChild & " ], ";
>                               
>               </cfscript>     
>                       
>               <cfreturn sChild>
>       </cffunction>
>       
>       <cffunction name="getChildren" access="public" returntype="query" >
>               <cfargument name="ParentID" type="numeric" required="Yes">

        <cfset var qTemp = this.List>
        <cfset var qChildList = 0>

>               <cfdump var="#Arguments#">
>               <cfset qTemp = this.List>

You can delete this line ^^^

>               <cfquery name="qChildList" dbtype="query">
>                       Select *
>                       From qTemp
>                       Where Parent_ID = #Arguments.ParentID#;
>               </cfquery>
>                       
>               <cfreturn qChildList>
>       </cffunction>
> </cfcomponent>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to