This was a question presented to me earlier today, and while it may be a yawn for many of you, I thought I'd review it here since it stumped me for a little while until I read the docs again.

The problem was that the calling page created a structure and populated a few struct keys with Strings, then passed the whole struct as input to a CFC method with [7 argumentcollection="#myStruct#" ...> when myStruct was a required input argument of type Struct, but the CFC returned the exception:

The parameter MYSTRUCT to function handleArgCollection is required but was not passed in.

The example presented to me was slightly deeper where CFC1 method1 was invoking CFC2 method1 and passing it the struct as an argumentcollection.

When listening to people explain problems its easy to supplant what you know about a subject with the suggestion of what is being described to you. The power of suggestion I suppose. So that is how I got sidetracked into building a reproducible case for this because for a while I forgot what I knew and assumed that what I was being shown was the right way to do it.

The problem was caused by identifying the Struct as a required input parameter of type Struct in method's cfargument tag and then referencing arguments.myStruct.keyname. The proper way to do this instead is to list the keynames as required arguments of type String (or whatever the keys contain), and then reference them by arguments.keyname.

To me, this issue exemplifies why I prefer to receive the shortest possible description of a problem with the smallest example code instead of listening to a lengthy description with extraneous code. Sometimes the power of suggestion just takes over your previous inclinations and pushes the solution that much further away. What I should have done first is to confirm what the docs say about how argumentcollections are handled:

When you pass an argumentCollection structure, each structure key is the name of a parameter inside the structure.


The example CFC invocation of Comp2 from the CFC Comp1 is:
[cfset var result = "">
[cfset var myStruct = structNew()>
[cfset myStruct["a"] = 1>
[cfset myStruct["b"] = 2>
[cfset myStruct["c"] = 3>

[cfinvoke
argumentcollection="#myStruct#"
component="Comp2"
method="handleArgCollection"
returnvariable="result" />


The CFC method argument declaration and usage that produced the error is:

[cfargument name="myStruct" required="yes" type="struct">
[cfset msg = arguments.myStruct["a"] & arguments.myStruct["b"] & arguments.myStruct["c"]>


And the corrected usage is:

[cfargument name="a" required="yes" type="string">
[cfargument name="b" required="yes" type="string">
[cfargument name="c" required="yes" type="string">
[cfset msg = arguments["a"] & arguments["b"] & arguments["c"]>