Welcome!

ColdFusion Authors: Yakov Fain, Pat Romanski, Liz McMillan, Maureen O'Gara, Greg Ness

Related Topics: ColdFusion, Adobe Flex

ColdFusion: Article

Steve Bryant's ColdFusion Blog: Using argumentCollection with Super

I found a solution in the comments of the ColdFusion LiveDocs

I recently had the need to use argumentcollection with super. Unfortunately, super can't be used with argumentCollection or with named arguments (which would allow me to loop through a structure and set arguments with cfinvokeargument).

Fortunately, I found a solution in the comments of the ColdFusion LiveDocs. As pointed out by "eblackey" (on "Using inheritance and the Super keyword"), if you copy super to this.super, you can then reference methods of this.super using argumentCollection or named arguments.

Adding this line to the pseudo-constructor (anything within <cfcomponent>, but not inside any method - that is not in <cffunction>), will copy super to this.super.
<cfset this.super = super>

Then, when calling a method ("myMethod()" in this example) of super from a method in your component, you can do this to pass all of the arguments of your method to super.myMethod:
<cfset this.super.myMethod(argumentCollection=arguments)>

Note that you won't be able to call private methods from this.super. If you have a constructor that is called when you first instantiate a component (an init method, for example), you might consider copying super there instead of in the psuedo-constructor so that you only make the copy when the component is instantiated and not every time that it is called.

This workaround solved the problem for me. I just started using it, so I will post again if I run into any trouble with it.

Until then, good luck!

UPDATE

This problem exists in ColdFusion MX 6.1, but not 7. See the following link for a related bug in CFMX 7:
http://ray.camdenfamily.com/index.cfm/2005/10/27/CFMX-7-and-Super-Fixes

Thanks to Brian Kotek and Sean Corfield for correcting my oversight.

posted Monday, 9 January 2006

More Stories By Steve Bryant

Steve Bryant is the founder and CEO of Bryant Web Consulting LLC (www.bryantwebconsulting.com) and teaches ColdFusion at Breakaway Interactive (www.breakawayinteractive.com). He got his BA in philosophy at Oklahoma State University. Steve, one of the top ColdFusion developers in the country, still has no idea how that led to a career in Web development. Steve blogs at steve.coldfusionjournal.com as one of CFDJ's published bloggers.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
SYS-CON Belgium News Desk 01/09/06 04:51:22 PM EST

I recently had the need to use argumentcollection with super. Unfortunately, super can't be used with argumentCollection or with named arguments (which would allow me to loop through a structure and set arguments with cfinvokeargument). Fortunately, I found a solution in the comments of the ColdFusion LiveDocs. As pointed out by 'eblackey' (on 'Using inheritance and the Super keyword'), if you copy super to this.super, you can then reference methods of this.super using argumentCollection or named arguments.