• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to pass array to cfc?

Guest
Mar 29, 2009 Mar 29, 2009

Copy link to clipboard

Copied

Hi,

Can anyone please help explain how to pass an array to a cfc?

I have a comma delimitered numeric string called "orderedMedia".

I create a new array:
<cfset orderArrayList=ArrayNew(1)>

I turn that string into an array:
<cfset orderArrayList = ListToArray(#orderedMedia#)>

I dump my results and can see the array just fine, but I cant figure out how to pass the array to my cfc. I just get the error message "You have attempted to dereference a scalar variable of type class coldfusion.runtime.Array as a structure with members."

Here is what I was attempted:
<cfinvoke component="cfc.media" method="orderMedia" argumentcollection="#orderArrayList#">

Any ideas please?

Cheers,

Aaron
TOPICS
Advanced techniques

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 29, 2009 Mar 29, 2009

Copy link to clipboard

Copied

LATEST
assuming your orderMedia cfc function expects/accepts an argument named
arrOrder of type Array:

<cfinvoke component="cfc.media" method="orderMedia"
arrOrder="#ListToArray(orderedMedia)#">

or

<cfinvoke component="cfc.media" method="orderMedia">
<cfinvokeargument name="arrOrder" value="#ListToArray(orderedMedia)#">
</cfinvoke>

or, if you want to use ArgumentCollection attribute, then you need to
first create a structure and populate it with member(s) and then pass it
to this argument:

<cfset args = structnew()>
<cfset args.arrOrder = ListToArray(orderedMedia)>
<cfinvoke component="cfc.media" method="orderMedia"
argumentcollection="#args#">

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation