[thelist] My dear CFASSOCIATEs

Raymond Camden jedimaster at macromedia.com
Thu Jul 26 07:13:00 CDT 2001


>
> basically cfassociate allows you to call a custom tag from within another
> custom tag and save the results of the sub tag with the results
> of the main
> custom tag.

I'm probably being anal, but this is somewhat off. CFASSOCIATE does not
"call" a custom tag in any sense - it simply passes information from a sub
tag to a parent tag. A good example (non cf) is a table.

<TABLE>
	<TR>
		<TD>..</TD>
	</TR>
</TABLE>

In this case, the TD tag, a child of a the TR tag, may want to pass
information to it's parent, and the CFASSOCIATE tag could be used to handle
that.

Of course, as you and Chris Evans said, there are easier ways of doing it,
for example, just using CFSET Caller.Foo. However, CFASSOCIATE can be useful
when you have a variable # of sub tags. Consider:

<CF_QuickForm>
	<CF_Element>
	<CF_Emenent>
	...
</CF_QuickForm>

CF_QuickForm is a custom tag I wrote to abstract simple forms. CF_Element
handles the creation of the form elements themselves, dropdowns, textboxes,
etc. So, if I had used the CFSET Caller.Foo type code, it would be possible
for me to overwrite data. I.e., I'd have to worry about the second
CF_Element screwing over the data from the first. By using CFASSOCIATE, I
can simply dump the data back to QuickForm and not worry about name
conflicts. Since information is stored in an array, I can simply loop over
the data that each CF_Element passed back to me.

Shameless Plug - There is a good example of this in Mastering ColdFusion
4.5, or Mastering ColdFusion 5, which is coming out in 1 week.

=======================================================================
Raymond Camden, Principal Spectra Compliance Engineer for Macromedia

Email   : jedimaster at macromedia.com
ICQ UIN : 3679482

"My ally is the Force, and a powerful ally it is." - Yoda





More information about the thelist mailing list