开发者

Can we pass a whole Structure over an URL?

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 possib开发者_JS百科le is there any simple method to do that ?


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


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") />


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜