Calling a ColdFusion Function Dynamically
Posted by spiraldev, Posted on June 5, 2009So I have this custom tag that displays a rates table for different things like products and classes everything is the same except the Foreign Key. I have my reasons for separate tables. But here was my problem I pass in my array of Transfer objects, and I loop over them but when I get to one field that is different I was using the evaluate function which I don't like to use. So I remembered that you can reference the name of the function and it will not execute so I did this.
Which did not work. So I am still using the evaluate function.
But when I try this on a test function I wrote. It works just fine.
So if anyone has any suggestions I am open and grateful.
Raymond Camden wrote on 06/05/09 3:11 PM
If you want to call a dynamic method on a component, don't forget you can use cfinvoke. It's more typing, but may be simpler, easier to read, and you don't have to create the copy.spiraldev wrote on 06/05/09 3:31 PM
What would be better cfinvoke or just doing calling the evaluate function?Ben Nadel wrote on 06/05/09 3:53 PM
Your two sets of sample code should do the *same* thing. I wonder why the first one didn't work.I second Ray's idea - CFInvoke is the nice solution:
<cfinvoke
. . . . returnvariable="result"
. . . . component="#TransferArray[1]#"
. . . . method="get#FKName#"
. . . . />
Raymond Camden wrote on 06/05/09 5:47 PM
@spiraldev: I think cfinvoke is 'better' simply because it feels better. The tag allows you to specify a dynamic component and a dynamic method, so to me, it fits the bill of being the right tool for the job. That being said, if I saw evaluate() being used, I wouldn't feel the need to change it.luxezico wrote on 11/09/09 8:55 PM
pnvuxvxo http://wvnoohkt.com imnqkcpp klyfyvky [URL=http://jflgqswf.com]ybydkukf[/URL] <a href="http://ggqwhxzv.com">sbrsnvfj</a>car lease deals wrote on 11/12/09 2:43 AM
Well this is very interesting indeed.Would love to read a little more of this. Great post. Thanks for the heads-up…This blog was very informative and knowledgeablecustom writing service wrote on 07/02/10 5:34 AM
Your post is an excellent example of why I keep coming back to read your excellent quality content that is forever updated. Your essay is so surprising and marvellous that I can’t stop reading it to the end.