Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a query to a cffunction via a cfform

Status
Not open for further replies.

jt8941

Programmer
Dec 9, 2003
15
US
All-

I think I read you can't pass complex obects(queries), to a function in a component without a <cfinvoke>.

i.e

<cfform method=&quot;post&quot; action=&quot;myComponent.cfc>
<input type=&quot;hidden&quot; name=&quot;method&quot; value=&quot;myMethod&quot;>
<input type=&quot;hidden&quot; name=&quot;myQuery&quot; value=&quot;#myQuery#&quot;>
...
</cfform>

will not work, the query results will not be passed...what are the ways around this, convert the query to an array? Any other thoughts?
 
Are you trying to dump a query into another language set? Ie CFM to ASP or CFM into Javascript?

Last time I checked the form structure doesnt allow objects to be passed between forms, so you will need to dump the query output (loop through it) to a form variable (list/array) then submit the form.

 
You are right, no complex datatypes can be sent this way. You could use <CFWDDX> if you ABSOLUTELY HAVE to do it this way.

However, if you are trying to persist this query across form submissions, then copy it to the session scope, assuming that you have session management set up.

<cfset Session.QueryData = Duplicate(MyQuery)>

Then, if you feel comfortable referencing the session scope within a component, do that. Otherwise, post to a cfm page, and call your <invoke> from there.

Kevin Nechodom
 
Session Variables are great Idea, I forgot about those. If I have to post from CFM to ASP I usually use Forms. If you need to keep other data around and its for CFM only then session/applcation vars are great for that.
 
I actually did it by using the ArrayToList() function before passing it, and then when I get it using the listToArray function to process it using a delimiter (the default was a comma which I use in the array...

I thought about session variables as well but I don't want it to stick around if they leave the page via-menu item...

This actually works pretty good...

<cfif isDefined(&quot;results&quot;)>
<cfif NOT #isArray(results)#>
<cfset arrayResults = #listtoArray(results,'/')#>
<cfset listResults = #results#>
<cfelse>
<cfset listResults = #arraytoList(results,'/')#>
<cfset arrayResults = #results#>
</cfif>
</cfif>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top