?
Solved

Application and Request Scope Disapearing when accessed from a Coldfusion CFC via CFAjaxProxy

Posted on 2010-04-07
7
Medium Priority
?
325 Views
Last Modified: 2013-12-24
I'm having some strange behaviour in my CFC that is being called via CFAjaxProxy.

I have a page that uses cfajaxproxy to run a sql query.

All the functionallity is correct and it works just fine if I specify the exact datasource name string in the CFC.

The DSN ofcourse should be handled by either #application.myDSN# or #REQUEST.app.myDSN#.

I have tried both the application scope and the request scope but then I get an error message saying:

"myDSN is not defined in Application" and "myDSN is not defiend in REQUEST".

I don't know why it looses these scopes.

Any advice would be greatly appreciated.

0
Comment
Question by:FastEddie___
  • 4
  • 3
7 Comments
 
LVL 27

Expert Comment

by:azadisaryev
ID: 30075085
is you cfc in a folder NOT under the folder of Application.cfc/cfm ?
0
 

Author Comment

by:FastEddie___
ID: 30081796
Yes it is Not under the same folder in which application.cfm is located.
It is in a different directory which is still under the webroot in a folder called cfcomponents.
That directory has many other cfc's that use the #application.dsn# variable with no problem.
 
0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 2000 total points
ID: 30087781
the other cfc (the ones that do work) are not accessed via cfajaxproxy, are they? otherwise they would not work either...

using cfajaxproxy and calling a cfc method via a js proxy is NOT the same as using crateobject or cfinvoke.

request-scope vars, and in your case - when your cfc is not under the Application.cfm - application-scope vars as well, will NOT be defined inside that call because this call is a completely separate request:
a) the request-scope vars defined in the calling page will not be available to remote cfc methods
b) since the cfc is NOT under the same application as the calling page, it can't see the application-scoped vars that the calling page can.

you have 2 choices:
1) pass the dsn name as an argument to your cfc method (you will need to edit the functions to accept that argument)
2) move the cfc to a location under the same Application.cfm as the page or set up an application proxy which extends your main Application.cfm in the cfc folder

Azadi
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 

Author Comment

by:FastEddie___
ID: 30118386
Yes Azadi, you are correct. The other cfc's are not accessed via cfajaxproxy.
Thank you very much for this explaination.
I'm curious about your solution #2. I'm using application.cfm not application.cfc.  
Is it possible to extend the .cfm file or do I have to convert it to a .cfc first?
Thanks.
 
0
 
LVL 27

Expert Comment

by:azadisaryev
ID: 30118862
>> Is it possible to extend the .cfm file or do I have to convert it to a .cfc first?

yes, you will have to convert it to Application.cfc in order to be able to extend it.
may be a good idea, since Application.cfc gives you so much more control over your app...

Azadi
0
 

Author Comment

by:FastEddie___
ID: 30121103
Excellent.  Thank you.
-Eddie
0
 

Author Closing Comment

by:FastEddie___
ID: 31712038
Thank you.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This installment of Make It Better gives Media Temple customers the latest news, plugins, and tutorials to make their Grid shared hosting experience that much smoother.
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question