0
Community Beginner
,
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/td-p/212504
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
I would like to pass complex structures via the URL. I know
this can be done using hidden fields in forms but sometimes, I need
to pass data from a file that is not a form. I'm having problems
getting this to work. I have a really simple file that sets up a
structure, serializes it using wddx and then attempts to pass the
serialized structure from a hyperlink. The file that is called
de-serializes the structure and tries to access it. I'm getting an
error:
WDDX packet parse error at line -1, column -1. Premature end of file..
on the de-serialization line. I know that things are serialized/de-serialized correctly because if I serialize and then deserialize in the same file (without passing it to another file via URL), I can access it fine.
Is it possible to send WDDX packets to another cfm file via the URL?
Here is my simplified code:
dsp_testPage.cfm
-------------------------
<cfset relatives=StructNew()>
<cfset relatives.field1 = "Dad">
<cfset relatives.field2 = "Mom">
<cfset relatives.field3 = "Sister">
<cfset relatives.field4 = "Brother">
<cfwddx action="cfml2wddx" input="#relatives#" output="wddxRelatives">
<br>
<a href="./index.cfm?fuseaction=test&relatives=#wddxRelatives#">Click Here</a>
--------------------------------------------------------------------------------------------------------------------
Then I have another page called index.cfm (I'm using fusebox) that looks like this:
<html>
<head></head>
<body marginheight="0" topmargin="0" marginwidth="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<cfparam name="attributes.fuseaction" default="home">
<cfswitch expression="#attributes.fuseaction#">
<cfcase value="home">
<cfinclude template="./dsp_DISPLAY/dsp_TESTPage.cfm">
</cfcase>
<cfcase value="test">
<cfwddx input="#attributes.relatives#" action="WDDX2CFML" output="localAppData">
<cfoutput>
<br>Inside Test<br><br>
field1 = #localAppData.field1#<br>
field2 = #localAppData.field2#<br>
field3 = #localAppData.field3#<br>
field4 = #localAppData.field4#<br>
</cfoutput>
</cfcase>
</cfswitch>
</body>
</html>
WDDX packet parse error at line -1, column -1. Premature end of file..
on the de-serialization line. I know that things are serialized/de-serialized correctly because if I serialize and then deserialize in the same file (without passing it to another file via URL), I can access it fine.
Is it possible to send WDDX packets to another cfm file via the URL?
Here is my simplified code:
dsp_testPage.cfm
-------------------------
<cfset relatives=StructNew()>
<cfset relatives.field1 = "Dad">
<cfset relatives.field2 = "Mom">
<cfset relatives.field3 = "Sister">
<cfset relatives.field4 = "Brother">
<cfwddx action="cfml2wddx" input="#relatives#" output="wddxRelatives">
<br>
<a href="./index.cfm?fuseaction=test&relatives=#wddxRelatives#">Click Here</a>
--------------------------------------------------------------------------------------------------------------------
Then I have another page called index.cfm (I'm using fusebox) that looks like this:
<html>
<head></head>
<body marginheight="0" topmargin="0" marginwidth="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<cfparam name="attributes.fuseaction" default="home">
<cfswitch expression="#attributes.fuseaction#">
<cfcase value="home">
<cfinclude template="./dsp_DISPLAY/dsp_TESTPage.cfm">
</cfcase>
<cfcase value="test">
<cfwddx input="#attributes.relatives#" action="WDDX2CFML" output="localAppData">
<cfoutput>
<br>Inside Test<br><br>
field1 = #localAppData.field1#<br>
field2 = #localAppData.field2#<br>
field3 = #localAppData.field3#<br>
field4 = #localAppData.field4#<br>
</cfoutput>
</cfcase>
</cfswitch>
</body>
</html>
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Community Beginner
,
Aug 28, 2007
Aug 28, 2007
Really silly mistake. In the file where I create the href
link, I need to place this inside a <cfoutput> tag in order
for the variable to be passed on the URL. It is working fine now
that I hadded the <cfoutput>.
I will continue to investigate JSON but I really need my app to be independent of Javascript (able to work when Javascript is turned off) so it may not be the best option for me.
Thank You.
I will continue to investigate JSON but I really need my app to be independent of Javascript (able to work when Javascript is turned off) so it may not be the best option for me.
Thank You.
Guide
,
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/m-p/212505#M19081
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/m-p/212506#M19082
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
If you want to keep using WDDX, you must encode the GET
string using the URLEncodedFormat function. i.e.
<a href="./index.cfm?fuseaction=test&relatives=#URLEncodedFormat(wddxRelatives)#">
Click Here</a>
I would investigate using JSON instead seeing as it is a lot less characters to send in a URL GET string. WDDX will make the string grow very fast.
If you want JSON and are on CFMX7, search for the CFJSON class. If you're on CFMX8, just use the SerializeJSON function.
<a href="./index.cfm?fuseaction=test&relatives=#URLEncodedFormat(wddxRelatives)#">
Click Here</a>
I would investigate using JSON instead seeing as it is a lot less characters to send in a URL GET string. WDDX will make the string grow very fast.
If you want JSON and are on CFMX7, search for the CFJSON class. If you're on CFMX8, just use the SerializeJSON function.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
beckyjmcd
AUTHOR
Community Beginner
,
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/m-p/212507#M19083
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
I added the URLEncodedFormat and a corresponding URLDecode
but I still get the error
WDDX packet parse error at line -1, column -1. Premature end of file..
I will also look into JSON.
WDDX packet parse error at line -1, column -1. Premature end of file..
I will also look into JSON.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/m-p/212508#M19084
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
I would honestly go with JSON instead.
To dig further into the WDDX, on the receiving end just prior to the WDDX2CFML - try outputting the WDDX string with CFOUTPUT and the HTMLCodeFormat function so that you can read it. Make sure the WDDX packet starts with something of the like:
<wddxPacket version='1.0'><header/><data>
and ends with something of the like:
</data></wddxPacket>
To dig further into the WDDX, on the receiving end just prior to the WDDX2CFML - try outputting the WDDX string with CFOUTPUT and the HTMLCodeFormat function so that you can read it. Make sure the WDDX packet starts with something of the like:
<wddxPacket version='1.0'><header/><data>
and ends with something of the like:
</data></wddxPacket>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Community Beginner
,
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/m-p/212509#M19085
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
Really silly mistake. In the file where I create the href
link, I need to place this inside a <cfoutput> tag in order
for the variable to be passed on the URL. It is working fine now
that I hadded the <cfoutput>.
I will continue to investigate JSON but I really need my app to be independent of Javascript (able to work when Javascript is turned off) so it may not be the best option for me.
Thank You.
I will continue to investigate JSON but I really need my app to be independent of Javascript (able to work when Javascript is turned off) so it may not be the best option for me.
Thank You.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/m-p/212510#M19086
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
I still think JSON is a multitude more optimal for what you
are trying to accomplish. It's a much more optimized (from a number
of characters standpoint) serialization method than WDDX which is
bloat in my opinion. It really has little to do with Javascript to
be honest - and as it is implemented in Coldfusion it is just a way
to serialize, that is all. No dependence on Javascript at all.
Good to hear it's working!
Good to hear it's working!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
beckyjmcd
AUTHOR
Community Beginner
,
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/m-p/212511#M19087
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
If the user is not required to have Javascript turned on in
their browser, then I can use it. I'm going to get what I have
working with wddx but I will definitely explore JSON.
Thanks!!
Thanks!!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
New Here
,
LATEST
/t5/coldfusion-discussions/can-i-pass-complex-data-using-wddx-via-a-url/m-p/212512#M19088
Aug 28, 2007
Aug 28, 2007
Copy link to clipboard
Copied
You missed the point, you can serialize Colfdusion Data in
JSON without any Javascript. This means that if the user is using a
javascript disabled web browser, it will still work. All the JSON
serialization, as well as WDDX serialization happens on the server
side.
Here's a CFJSON class I've used:
http://www.epiphantastic.com/cfjson/
Here's a CFJSON class I've used:
http://www.epiphantastic.com/cfjson/
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

