• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 863
  • Last Modified:

CF8 CFLAYOUT can't directly access query / session variables - AJAX issue?

Inside my CFLAYOUT I have 3 tabs. I run CFQuery on the CFLAYOUT parent page,  and use CFIF ThatQuery.recordcount GT 1... in each of the 3 tabs to determine what to display. It doesn't find the variable "recordcount" because it can't access / use any of the query or session variables on each of the tabs. Using CFDUMP results in pop-up error "Error retrieving markup for element tab1: Variable SESSION is undefined..." Same for Query variable. Form variables seem to work though. <CFDUMP VAR="#form#"> works. It's as if some CFML doesn't get processed on the tabs, only HTML layout info does. The query results and session variables are clearly listed in the CFDebugger.
2 Solutions
So you're only displaying the tab if there are more than 1 record??  First check that... I would gues that either <cfif ThatQuery.recordcount GTE 1> OR <cfif ThatQuery.recordcount> is what you want (just verifying that there was a record returned from the database at all.  I can understand that you wouldn't be able to see the session information, because the AJAX is essentially a client-side technology that merely communicates with the server layer for it's data, not for it's operation or variable storage.  The form scope is available to the page as would variables set in javascript.  If the values in session are static when the page loads you can either output them into a js area (<script>) or you could write them out via either FORM scope or the URL scope (both of which would be available to the local page.
Are you using the source parameter of the cflayoutarea tag?   If so, you are calling another template just like you would call an iFrame.   It's being loaded from the client side like an iFrame call and would have none of the coldfusion variables unless you pass them in.    In this case you have to consider the source page called just like a stand-along page you can open in the browser... take whatever you have in source and put it in the address bar and see what opens.  

I am surprised that you don't see session variables as they persist in your session.  Keep in mind that the application.cfm file is being called as part of the tab opening the template.

It makes sense that you don't see the query variables from the main page.  You should only see form variables that you generate in the tab page loaded.  

Let me know if you're not using source, perhaps post some code would help

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now