I thought it might
be nice to have a list of valid method names when initiating an object so I'd be
able to make sure I didn't try to run a method (perhaps based on user input)
that was inappropriate. Of course, I could use try/catch but that wouldn't
distinguish between calling invalid methods and errors within the
method.
Anyhow,
getMetaData() works fine, but I ran into problems getting a clean method
list:
<cfset Local.TempMetaData =
getMetaData(THIS)>
<cfset Local.FunctionList = Local.TempMetaData.Functions>
<cfset THIS.MethodList = Local.FunctionList[1].Name>
<cfset Local.FunctionList = Local.TempMetaData.Functions>
<cfset THIS.MethodList = Local.FunctionList[1].Name>
Successfully returns
the name of the first method of the object.
Trying to loop
through them as below gives "Invalid collection "[Ljava.lang.Object;@1f4c4a3" -
must be a valid struct or COM object. "
<cfloop collection="#Local.FunctionList#"
item="Count">
<cfset ThisVal = Local.FunctionList[#Count#].Name>
<cfset THIS.MethodList = ListAppend(THIS.MethodList,ThisVal)>
</cfloop>
<cfset ThisVal = Local.FunctionList[#Count#].Name>
<cfset THIS.MethodList = ListAppend(THIS.MethodList,ThisVal)>
</cfloop>
I have a feeling
this is a simple syntax problem but am not sure . . . Anyone have simple code
for returning a list of methods?
FYI, I know Sean
suggested some time back that run time introspection doesn't scale, but by only
running this routine on a small number of objects that I persist throughout an
application and by only calling it once on object creation I'm betting the
performance overhead will be minimal.
Best
Wishes,
Peter
----------------------------------------------------------Peter
You are subscribed to cfcdev. To unsubscribe, send an email to cfcdev@cfczone.org with the words 'unsubscribe cfcdev' as the subject of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).
An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org