Passing cfquery to a cfc function from an element bind attribute

171 Views Asked by At

I have a cfc function that accepts a query type argument (with the intent of running a query of query). I am able to call the function successfully using <cfinvoke>. However, what I really want to do is call the function from a hidden <cfinput>'s bind attribute, using bind="cfc:cfcname.somefunction(queryVar)", and that code fails. There is no visible error, but it doesn't look like my function ever gets called - I have a cflog in there. [The reason for the bind is not really relevant to my question, but it is because I need the function call to react to another control on the form - I've distilled all that out of my question]

If I replace the queryVar with some string variable, the function gets called fine, but obviously I cannot get the results I want without passing the query in. If I use bind="cfc:cfcname.somefunction(#queryVar#)", I get a

"Complex type cannot be converted to simple type"

error. I've searched for any documented restriction on passing query (or any complex type) to a cfc from a bind, but haven't found a clue.

1

There are 1 best solutions below

2
Bobmd On

You can use "bind" to send user-inputted data to another page for processing then send back the results. For example, If you use "bind" on a Birthdate field. When the user selects their birthdate, you can send that date to a CFC or CFM page and have it do the math #DateDiff('yyyy',birthdate,Now())# and return the result, which would be how many "years old" the user is.

But to my knowledge, you can't send a query to another page via the "bind" function. However, you could run the query again on another page and return the results.

Or perhaps look into JQuery to handle further processing after the page has loaded.