CF9 Structures and StructFindValue
I'm working on a multipage survey, and I'd like to store the answers in a structure.
First I create an array:
<cfset answerarray = arrayNew(1)>
Then I create a structure, and I loop through the questions in the survey and store the data.
<cfset ArrayPosition=1>
<cfset answerarray[ArrayPosition] = structNew()>
<cfset answerarray[ArrayPosition].CategoryID=CategoryID>
<cfset answerarray[ArrayPosition].QuestionID=QuestionID>
<cfset answerarray[ArrayPosition].AnswerValue=AnswerValue>
Then I convert the structure data to WDDX.
<CFWDDX action="CFML2WDDX" input="#answerarray#" output="wddx_answerarray">
And I store it in a hidden field.
<form action="test4.cfm" method="post">
<cfoutput>
<input type="hidden" name="wddx_answerarray" value="#wddx_answerarray#">
</cfoutput>
<input type="submit">
</form>
That all works great, and on the next page, I convert the data back to a structure.
<cfif IsDefined("wddx_answerarray")>
<CFWDDX action="WDDX2CFML" input="#wddx_answerarray#" output="answerarray">
</cfif>
If I do a cfdump at this point, I get something like this:
| array | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| 1 |
| ||||||||
| 2 |
| ||||||||
| 3 |
| ||||||||
| 4 |
| ||||||||
So what I'd like to do is check to see if there is a specific categoryID stored in the structure, so I did the following:
<cfset match=StructFindValue(answerarray,"1","all")>
<cfdump var="#match#">
But I get the error:
You have attempted to dereference a scalar variable of type class java.util.Vector as a structure with members.
I've got no idea what I'm doing wrong. Any pointers would be greatly appreciated.
Thanks,
Jim