开发者

coldfusion "String index out of range" error with argumentcollection

I'm passing form variables in a cfinvoke argument collection:

<cfinvoke component="#application.com开发者_JAVA百科ponentPath#.account" method="updateServices" argumentcollection="#form#" />

But I keep getting the error: "String index out of range: 0 null" I've narrowed it down to something to do with the form variables passed in the argumentcollection. When I do a <cfdump var="#form#">, it looks like this:

form - struct

EMAIL_1 wendy 
EMAIL_2 [empty string] 
EMAIL_3 [empty string] 
EMAIL_4 [empty string] 
FIELDNAMES EMAIL_1,EMAIL_2,EMAIL_3,EMAIL_4, 

(I can't do a screenshot of the struct so you'll have to imagine it.)

If I lose the argumentcollection from the cfinvoke, the error disappears.

The receiving CFC:

<cffunction name="updateServices" access="public" output="true" returntype="void">

     <!--- deliberately emptied to see if it was anything inside the cfc causing the issue--->

</cffunction>

Any assistance appreciated.


We can't see what's going on in your component, so this is a guess. When you use argumentcollection with <cfinvoke> and pass in a struct, the struct is broken out in the component as if its elements had been passed in as individual arguments. So if you have:

<cfset foo.this = 1>
<cfset foo.that = 2>

<cfinvoke...argumentcollection="#foo#">

...then inside the component you'll have:

arguments.this; // 1
arguments.that; // 2

You will not have arguments.foo.this, nor foo.this. So if you want to pass in your form scope and have it encapsulated inside the component, you can try this:

<cfinvoke...formscope="#form#">

Then, inside the invoked component method, you'd be able to use:

arguments.formscope.EMAIL_1
arguments.formscope.EMAIL_2
arguments.formscope.FIELDNAMES

...etc. You might also look into <cfinvokeargument>. If none of this helps, maybe posting a bit of what happens inside the component will shed further light.


The only thing I see that might be wrong is:

component="#application.componentPath#.account"

Try hard-coding that to a cfc path that you know exists (com.whatever.account), and if it then works, then you know what was causing the problem (the dynamic component expression).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜