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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.