views:

123

answers:

5

Hi, I am opening a new popup window on click of an URL in my page. My question over here is Can i pass whole structure to the new page ?

If thats not possible is there any simple method to do that ?

A: 

You can add your data points as parameters to the end of the URI, but I do not suggest using the method you see as it would be highly subject to injection.

Data points ! you mean all the values and keys in the struct ?
Somu
Yes, because a parameter is typically a named entity and its assigned value.
+1  A: 

Although HIGHLY NOT recommended, you could do this:

<cfset tmp = {} />
<cfset tmp.name="Marcos" />
<cfset tmp.lname="Placona" />

<cfwddx action="cfml2wddx" input="#tmp" output="tmpWDDX">

<a href="index.cfm?string=#tmpWDDX#">link</a>

If you decide to take this approach, I'd suggest sending the information via form as opposed to URL.

You always have the option to store the data in a persistent object such as a bean, or a more simple approach such as a session.

Hope this helps you

Marcos Placona
Thanks Marcos.It may help but as you said its highly NOT REcommended i have to think a different way to do that.
Somu
+7  A: 

Is the page being opened in the URL part of the same application?

If so a better way would be to save the structure in the user's session and pull in the information in that way. Cleaner URLs, code and more secure.

Cheers, James

James Buckingham
Yes. The new page is of the same application.As i am totally new to COldFusion have to figure out how it is exactly done.Thanks
Somu
That's how I would do it.
Al Everett
A: 

Serializing Struct (with serializeJSON() or something) and puttin git in URL seems reasonable in case struct is not too big (read: less than 3-4k characters in total).

Other solution would be to put this in some shared scope: session, application etc.

Third, would be to call cfm with POST request which can handle larger structs then GET.

zarko.susnjar
+1  A: 

Expanding on James Buckingham's answer...

(This assumes you have session management set to true.)

In the calling page, simply copy your structure to a session variable:

<cfset session.myTempStruct=variables.myTempStruct />

Then, in the popup, copy the structure back to the local scope for that request:

<cfset variables.myTempStruct=session.myTempStruct />

If you don't want that structure to hang around in the session, you can have the request for the popup remove it from the session right after copying it to the local scope.

<cfset structDelete(session, "myTempStruct") />
Al Everett