Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Retrieving server details inside application.cfc when CFC called from Flex

New Here ,
Jun 08, 2010 Jun 08, 2010

Retrieving server details in application.cfc when calling CFC from Flex

I'm having trouble retrieving processing info inside of application.cfc when calling a CF CFC from Flex.

I have 2 ColdFusion applications on a CF 7.0.2 server.  These applications both provide the same exact functionality, but one is “Production” and the other is “Training”.  The source code for each is in its own folder under the webroot of the server, one folder is called “MyAppProd” and the other is “MyAppTrain”. 

Each application maintains its own set of “application” scope variables.  I determine which app is being run by examining the value of CGI.SCRIPT_NAME at the top of the application.cfc file.  If “/MyAppProd/” is found in script_name, then this.name (application scope name) is set to “PROD”.  If “/MyAppTrain/” is found in script_name, then this.name is set to “TRAIN”.  Then my onApplicationStart() function evaluates the value of this.name in order to set the application scope variables to the appropriate values, based on which app is actually being run.  Here’s a shell of the code:

<cfcomponent>

            <cfif find(“/MyAppProd/”,#cgi.script_name#) NEQ 0>

                        <cfset this.name = “PROD”>

            <cfelseif find(“/MyAppTrain/”,#cgi.script_name#) NEQ 0>

                        <cfset this.name = “TRAIN”>

</cfif>

            <cffunction name=”onApplicationStart”>

                        <cfif this.name EQ “PROD”>

                                    <!--- set app scope vars for PROD --->

                        <cfelseif this.name EQ “TRAIN”>

                                    <!--- set app scope vars for TRAIN --->

                        </cfif>

            </cffunction>

</cfcomponent>

This process works great for strictly ColdFusion scripts and it has been in production for a year and half.  However, I recently implemented some Flex 3 charting functionality to the mix and I now have issues identifying which application scope should be used when Flex tries to retrieve its data from the ColdFusion CFC that I’m calling. 

My problem is simply identifying which app scope to attach the request to.  The CF server ends up trying to execute onApplicationStart() again because the processing falls through the CFIF condition that attempts to identify the app directory.

I’ve tried checking the value of other CGI variables as well (like PATH_INFO and CF_TEMPLATE_PATH) but none of them seem to have the values that they have when executed directly from a CF script. 

So my question is…

How can I retrieve request/script/server processing information when a request is generated from Flex?  I know that requests get processed through the flex2gateway directory, but how does the server know or keep track of which script is getting executed?  Somehow, I need to be able to identify which app directory the script (CFC file) is being executed from.  Any ideas???

By the way, the Flex chart rendered just fine on my Dev server where there’s only the one default application, so I know there’s no issues with returning the data from CF to Flex. 

Thanks!

Kevin

TOPICS
Flash integration
719
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 04, 2010 Oct 04, 2010
LATEST

Hi,

This is what I do:

1)

In my flex app I have a global variables set in an AS file like:

package
{
  public class settings
  {
    static public var myApplication = "myApp01";

}

Then everytime I call a cfc I pass this name as paramenter.

2)

Use application.cfc to set a sesion variable name with your application name.

In your cfc just check for that name like: #application.myApp#

I hope this help.

Johnny

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources