Hi Laura,
I played around with your code and made a few changes , the following code
works for me:
In the form page:
<cfset janarray= arraynew(1)>
<cfset janarray[1]="A">
<cfset janarray[2]="B">
<cfset janreq = StructNew()>
<cfset janreq["jan"] = janarray>
<cfwddx input="#janreq#" output="janwddx" action="cfml2wddx">
<!---
In the form - --->
<form action="JanArray2.cfm" method="post">
<p>
<cfoutput><input type="hidden" name="wddxarray"
value="#janwddx#"></cfoutput>
<p><input type="submit" value="submit">
</form>
In the action page:
<cfwddx action="wddx2cfml" input="#form.wddxarray#" output="letsee">
<!--- create and fill a local array jan info --->
<cfset month=arraynew(1)>
<CFSET month=#letsee["jan"]#>
<!--- make sure the array's length is right this will give 2 which is
correct--->
<cfoutput>#ArrayLen(month)#</cfoutput><br>
<!---out put the array which gives A and B , it is right--->
<cfoutput>
<cfloop from="1" to="#ArrayLen(month)#" index="x">
#month[x]#<br>
</cfloop>
</cfoutput>
The changes I made is:
1. put a <cfoutput> around the hidden field.
2. moth is a one diamension array so should be referenced like month[x] not
month[ ][ ].
3. Remove the htmlformat() function in the hidden field's value. If you put
it back I got an error just like you got "unknown element encountered".
Hope this helps
Sima
|--------------------|
| |
|--------------------|
"Harper,
Laura" To: CF-Talk <[EMAIL PROTECTED]>
<Laura.Harper cc:
@AIG.com> Subject: Deserialize array from wddx
packet
01/03/01
11:41 AM
Please
respond to
cf-talk
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C075AC.6E6BB0F0
Content-Type: text/plain;
charset="iso-8859-1"
Happy New Year everyone!
I have a page where I need to pass 12 arrays (one for each month of the
year) to another page. I have never used arrays with wddx before so I'm
testing using just one array, for simplicity. The serialization piece is
working. The problem is with the deserialization. This error message
"unknown element encountered" appears. My code is as follows:
Serialize code:
The array name is janarray.
<cfset janreq = StructNew()>
<cfset janreq["jan"] = janarray>
<cfwddx input="#janreq#" output="janwddx" action="cfml2wddx">
In the form - <input type="hidden" name="wddxarray"
value="#htmlcodeformat(janwddx)#">
The output of this is:
<wddxPacket version='0.9'><header></header><data><struct><var
name='JAN'><array
length='36'><string>0.0</string><string>0.0</string><string>0.0</string>
This continues since there are 36 elements to the array, but I think you
get
the idea.
Deserialize code:
<cfwddx action="wddx2cfml" input="#form.wddxarray#" output="letsee">
<!--- create and fill a local array jan info --->
<CFSET month=#letsee["jan"]#>
<cfoutput>
<cfloop from="1" to="#ArrayLen(month)#" index="x">
#month[x]["jan"]#
</cfloop>
</cfoutput>
Any hints as to what I'm missing are greatly appreciated. I've been
working
on this for a while and I'm getting a headache! What a way to start the
new
year. Thanks in advance.
Regards,
Laura
------_=_NextPart_001_01C075AC.6E6BB0F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>Deserialize array from wddx packet</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=3D2>Happy New Year everyone!</FONT>
</P>
<P><FONT SIZE=3D2>I have a page where I need to pass 12 arrays (one for =
each month of the year) to another page. I have never used arrays =
with wddx before so I'm testing using just one array, for =
simplicity. The serialization piece is working. The problem =
is with the deserialization. This error message "unknown =
element encountered" appears. My code is as follows:</FONT></P>
<P><FONT SIZE=3D2>Serialize code:</FONT>
<BR><FONT SIZE=3D2>The array name is janarray.</FONT>
</P>
<P><FONT SIZE=3D2><cfset janreq =3D StructNew()></FONT>
<BR> <FONT SIZE=3D2><cfset =
janreq["jan"] =3D janarray></FONT>
<BR> <FONT =
SIZE=3D2><cfwddx input=3D"#janreq#" =
output=3D"janwddx" action=3D"cfml2wddx"></FONT>
</P>
<P><FONT SIZE=3D2>In the form - <input type=3D"hidden" =
name=3D"wddxarray" =
value=3D"#htmlcodeformat(janwddx)#"></FONT>
<BR><FONT SIZE=3D2>The output of this is:</FONT>
<BR><FONT SIZE=3D2><wddxPacket =
version=3D'0.9'><header></header><data><struct&g=
t;<var name=3D'JAN'><array =
length=3D'36'><string>0.0</string><string>0.0</s=
tring><string>0.0</string> This continues since =
there are 36 elements to the array, but I think you get the idea. =
</FONT></P>
<P><FONT SIZE=3D2>Deserialize code:</FONT>
<BR><FONT SIZE=3D2><cfwddx action=3D"wddx2cfml" =
input=3D"#form.wddxarray#" =
output=3D"letsee"></FONT>
</P>
<P><FONT SIZE=3D2><!--- create and fill a local array jan info =
---></FONT>
<BR><FONT SIZE=3D2><CFSET =
month=3D#letsee["jan"]#></FONT>
</P>
<P><FONT SIZE=3D2><cfoutput></FONT>
<BR><FONT SIZE=3D2><cfloop from=3D"1" =
to=3D"#ArrayLen(month)#" index=3D"x"></FONT>
<BR><FONT SIZE=3D2>#month[x]["jan"]#</FONT>
<BR><FONT SIZE=3D2></cfloop></FONT>
<BR><FONT SIZE=3D2></cfoutput></FONT>
</P>
<P><FONT SIZE=3D2>Any hints as to what I'm missing are greatly =
appreciated. I've been working on this for a while and I'm =
getting a headache! What a way to start the new year. =
Thanks in advance.</FONT></P>
<P><FONT SIZE=3D2>Regards,</FONT>
</P>
<P><FONT SIZE=3D2>Laura</FONT>
</P>
<BR>
<BR>
<BR>
</BODY>
</HTML>
------_=_NextPart_001_01C075AC.6E6BB0F0--
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists