Title:
Bug 86892:GetComponentMetaData functions array unable to be iterated using for
| View in TrackerStatus/Resolution/Reason: Closed/Fixed/
Reporter/Name(from Bugbase): Phil Haeusler / Phil Haeusler (phil haeusler)
Created: 05/04/2011
Components: Language, CFSCRIPT
Versions: 10.0
Failure Type: Unspecified
Found In Build/Fixed In Build: 0000 / 279825
Priority/Frequency: Trivial / Unknown
Locale/System: English / Win All
Vote Count: 6
Problem:
GetComponentMetaData functions array unable to be iterated using for...in loop in cfscript
Method:
The Functions array returned by GetComponentMetaData() is unable to be iterated over using a cfscript for...in loop. The following run-time error is receivedYou have attempted to dereference a scalar variable of type class [Ljava.lang.Object; as a structure with members. Looping over the array using <cfloop array="" index=""> works fine, as does looping over the array using an index counter in cfscript.Manually adding each element from the functions array into a new array allows new array to be iterated over using a for...in cfscript looptest.cfm---------
<cfset details = GetComponentMetaData("TestComponent")>
<cfloop array="#details.functions#" index="method">
<cfoutput>#method.name#()<br /></cfoutput>
</cfloop><hr>
<cfscript>// this for...in statement does not workfor(method in details.functions) {writeOutput(method.name & "()<br />");}</cfscript><hr><cfscript>// This works - shows the functions array can be iterated over using an index counter.functions = [];for(i=1; i lte ArrayLen(details.functions); i=i+1) {ArrayAppend(functions, details.functions[i]);}// Adding all the elements from the original functions array to a new one allows for...in loop to workfor(method in functions) {writeOutput(method.name & "()<br />");}</cfscript>
TestComponent.cfc-----------------
<cfcomponent>
<cffunction name="helloWorld" returntype="string"> </cffunction></cfcomponent>
Result:
You have attempted to dereference a scalar variable of type class [Ljava.lang.Object; as a structure with members.
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 3043807
External Customer Info:
External Company:
External Customer Name: Phil Haeusler
External Customer Email: 361F280E425B9CD5992015D5
External Test Config: 05/04/2011
Attachments:
Comments: