What is the best way to make a query object in a document available to an iframe (with a .cfm file as the source of the iframe) in that document?
An iframe is just another window. If it is loading a .cfm file then how woudl you get that query object into any other .cfm file?
Don't let the source being loaded in an iframe confuse you. It's just another .cfm file. It doesn;t become an iframe til it reaches the client, and at that point it is long past ColdFusion's control. If you're thinking that the parent window will somehow pass a CF query to the iframe window, then you're thinking along the wrong track. The parent window is makign the request for the iframe document after it has left the server. It no longer has any concept of what a ColdFusion query is.
If you need to ensure that the parent window and the iframe run the same dynamic query then you could do something like this:
1. User requests the parent window
2. Dyanmic query is run
3. Query is cached in the App or session scope with a Unique key
4. Iframe is created using that unique key (example: <iframe src="/childPage.cfm?queryKey=34jkldsflhsfdsdf" />)
5. When iframe is loaded by the browser it receives that key, looks up the query in the cache and uses it instead of making a new query.
I did NOT think that the parent window will somehow pass a CF query to the iframe window; that's why I came into this forum to ask.
I had thought about inserting the query object into the session scope, but didn't know how to do so.
So, which is best, Application scope, or Session scope? And will a simple CFSET SESSION.VariableName = CFQUERYOBJECT work? I didn't think a simple variable could contain a complex object?
>> So, which is best, Application scope, or Session scope?
If the data is user specific, then probably the session scope. Performance-wise, either one should be fine.
>> And will a simple CFSET SESSION.VariableName = CFQUERYOBJECT work? I didn't think a simple variable could contain a complex object?
What makes a variable simple or complex is its content.
<cfset session.key = 1 /> Creates a simple variable
<cfset session.key = structNew() /> Creates a complex variable
Yes, session.key = queryObject will work just find.
In the parent document, I coded "<cfset session.query1 = queryName>", and in the iframe document, I coded "SELECT * FROM #session.query1# WHERE id=#url.id#" and am getting the error message that complex object types cannot be converted to simple values. Do I need to set the session variable to StructNew(), first?