[thelist] My dear CFASSOCIATEs

.jeff jeff at members.evolt.org
Wed Jul 25 19:18:09 CDT 2001


rory,

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: Rory.Plaire at wahchang.com
:
: There seems to me, as lethargic as my
: comprehension is at times, to be a
: lamentable lack of coverage on the
: CFASSOCIATE tag.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

probably for two reasons:

1) very few people need to do what it does
2) there are better ways of doing what it does
   or doing that sort of thing it'd be used for

if that's not as clear as mud.  *grin*

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.

the reason few people need it is because there are very few times you really
need to call a custom tag from within another custom tag.  furthermore,
there are often good reasons not to do that (performance being one of them)
and better ways of accomplishing the task without calling a sub tag.

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: Is there some one who can provide a clear
: and sharp perspective for this poor one for
: whom the distinction of what data in which
: tag ends up where is about as muddy as one
: of the greatest electric blues musicians of
: all time?
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

upon your poser does my explication dispense illumination?

:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: I am trying to write a custom tag which returns
: a value or two.  [...] Based on all of this database-
: querying, rule-applying, put-it-in-the-blender-and-
: press-puree activity, either the data passed to this
: custom tag (web form data) is valid or not. If it is
: not valid, the tag needs to return several values,
: like measure of success and error message.
:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

one way would be to create a variable in the caller scope and put the
results there.  another way might be to allow the specifying of a variable
that data gets put into -- to prevent the chance that the variable you'd
choose might be used for something else by someone who might eventually use
the tag.

consider the cffile tag with an action of read.  you have a "variable"
attribute where you specify the variable to place the contents of the file.
why not do that with this?

calling the tag:

<cf_dqrapiitbapp
 ...
 various attributes
 ...
 variable="dqrapiitbapp_result">

inside the custom tag itself:

<cfparam name="attributes.variable" default="">

<!--- check to make sure the variable attribute has a value --->
<cfif NOT Len(Trim(attributes.variable))>
  <cfabort showerror="You must specify a variable that you wish to contain
the results of this tag">
</cfif>

<cfparam name="caller.#attributes.variable#" default="">

....
do your magic -- dqrapiitbapp
....

<!--- set the return value --->
<cfset caller.#attributes.variable# = "your return value">

from the calling template, after calling the custom tag, you should be able
to get the return value by calling the variable you specified in the
variable attribute when calling the tag:

<cfoutput>
#dqrapiitbapp_result#
</cfoutput>

btw, there's a better way of paraming and setting that variable than using
hashes on the left side of the assignment operator (equal sign), but it's
been a long day and i'm drawing a blank what that method is.

good luck,

.jeff

http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/







More information about the thelist mailing list