Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to test an object against a component type and/or inherited type?

Tags:

coldfusion

cfc

Update: Based on the answers I initially went the route of using IsInstanceOf() which was designed for this need. However it turned out to be extremely inefficient for some unknown reason. In debugging the app later I ended up just setting some properties on the object to use instead of IsInstanceOf resulting in orders of magnitude speed improvement.

What I am trying to do is test an object in ColdFusion to see what type of component it is. Something like...

<cfif isValid( "compath.dog", currentObj)>
    ...do something specific with dog objects...
</cfif>

I thought this was possible but receive an error saying the type I am passing does not correspond to one in the valid list of types...

Valid type arguments are: any, array, Boolean, date, numeric, query, string, struct, UUID, GUID, binary, integer, float, eurodate, time, creditcard, email, ssn, telephone, zipcode, url, regex, range , component, or variableName.

Is there a way to accomplish this in ColdFusion?

like image 473
Dan Roberts Avatar asked May 18 '09 19:05

Dan Roberts


Video Answer


1 Answers

You could use GetMetaData to find the type. Some quick code:

<cfif GetMetaData(currentObj).type eq "compath.dog">
like image 171
Sam Farmer Avatar answered Oct 12 '22 22:10

Sam Farmer