Using New ColdFusion 4.0.1 and 4.5 Features ColdFusion Help

Starting with Cold Fusion 4.0.1, the server contains numerous new functions and features: One of the new features is the ATIRIBUTE COLLEaI ON attribute. You can use this attribute to send dynamic attributes to a custom tag. To implement this feature you must first create a structure. Each element of the structure should be a name-value pair. For example:

<CFSET EXTRA_ATTRIBUTES – StructNew(»
<CFSET EXTRA-ATTRIBUTES.Age – 25>
<CFSET EXTRA_ATTRIBUTES.Sex – ‘Male’>
<CFSET EXTRA_ATTRIBUTES. Job – ‘Jldi’>
<CF_CreatePersonUSERNAME-‘morpheus’ ATTRIBUTECOLLECTION-‘#EXTRA_ATTRIBUTES#’>

This is the same as

<CF_CreatePerson USERNAME-‘morpheus’ AGE-2S SEX-‘Male’ JOB-‘Jedi’>

You can also do the same with CFMODULE:

<CFMDOULE TEMPLATE-‘create person .cfm’,USER NAME-‘morpheus’
ATTRIBUTE COLLECTION-“EXTRA_ATTRIBUTES#’>

Within the custom tag attributes passed via ATIRIBUTE COLLECTION are accessed the same as any standard attribute

This new feature is useful if the arguments you need to send to a custom tag can change on a case-by-base basis. Using ATIRIBUTE COLLECTION and CFIF statements you can dynamically create the attributes your tag needs depending on the situation.

Because of this new feature bear ‘in mind that you now cannot use ATIRIBUTE COLLECn ON as an attribute name for any other purpose aside from passing in a structure

Where Do We Go from Here?

In the next chapter you will look at ways to extend ColdFusion to use external objects. Specifically, you will consider the use of Component Object Model (COM) objects. In the Windows environment COM objects provide an interface that programs can use to provide services to other programs.and through this environment ColdFusion templates can access a wide variety of capabilities not built into the ColdFusion environment .

Posted on November 17, 2015 in Building ColdFusion Custom Tag

Share the Story

Back to Top
Share This