Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
498 views
in Technique[技术] by (71.8m points)

coldfusion - Passing cfquery to a cfc function from an element bind attribute

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...