> On Friday, Mar 28, 2003, at 10:59 US/Pacific, S. Isaac
> Dealey wrote:
>> <cffunction name="getValue" ouptut="false">
>> <cfargument name="propertyname" type="string"
>> required="true">
>>
>> <cfif isdefined("this.get_" & propertyname)>
>> <cfreturn evaluate("this.get_#propertyname#()")>
>> <cfelse>
>> <cfreturn this[propertyname]>
>> </cfif>
>> </cffunction>
> Eek! Evaluate! :)
> Try this instead:
> <cffunction name="getValue" ouptut="false">
> <cfargument name="propertyname" type="string"
> required="true">
> <cfset var fn = 0>
> <cfif structKeyExists(this,"get_" & propertyname)>
> <cfset fn = this["get_" & propertyname]>
> <cfreturn fn()>
> <cfelse>
> <cfreturn this[propertyname]>
> </cfif>
> </cffunction>
You're right, my bad. :) I was in a hurry...
structkeyexists() is also better than isdefined() imho since it's more
specific although I wasn't entirely sure it would produce the desired result
in this context. I expected it to, but fell back on what I was more certain
of for the sake of the example in case somebody tried to run it.
I wonder if <cfreturn this["get_" & propertyname]()> would produce an
error... It sure looks funky...
I can never avoid using evaluate in Tapestry because it still supports CF 5
and because of the structure of the application ( lots of includes and
custom tags ) if I use array notation it invariably produces an unknown
exception condition somewhere that I then have to isolate as a result of an
obscure CF5 bug. There's only like 3-5 people in the whole CF world really
affected by it. And it always turns out to be _that_ problem and the only
workaround I've found is evaluate() unfortunately...
I'm sure MX doesn't have the same problem as I'm pretty certain the bug was
related to some core low-level pcode functionality.
s. isaac dealey 954-776-0046
new epoch http://www.turnkey.to
lead architect, tapestry cms http://products.turnkey.to
tapestry api is opensource http://www.turnkey.to/tapi
certified advanced coldfusion 5 developer
http://www.macromedia.com/v1/handlers/index.cfm?ID=21816
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4