Skip navigation
Currently Being Moderated

ussue with application.cfc in flash remoting

Jun 22, 2012 4:29 AM

<cfcomponent

    output="false"

    hint="I define the application settings and event handlers.">

 

hi, im using flash remoting to call cfcs and I want to use this application.cfc to determine the environment (the APPLICATION.environment defines a DSN used in the cfcs flash calls).

 

however everytime I call a cfc with this app.cfc I get a error from CF which I can't debug because CF builder is uselss for connecting to debuggers. Any ideas?

 

    <!--- Define the application. --->

    <cfset this.name = hash( getCurrentTemplatePath() ) />

    <cfset this.applicationTimeout = createTimeSpan( 0, 0, 1, 0 ) />

 

   

<cffunction name="onApplicationStart" output="false">

     

      <cfset path = cgi.SERVER_NAME & cgi.SCRIPT_NAME>

     

     <cfset serverAnd2Dirs = reFind("([\w-]+/\w+/\w+)",path,0,true)>

    <cfset match = mid(path, serverAnd2Dirs.pos[1], serverAnd2Dirs.len[1])   >

   

   <cfset var identifier = createObject("component","DomainEnvironmentIdentifier").init(match)>

    <cfset var environment = createObject("component","Environment" ).init(expandPath('/')&"coldfusion\config\environments.xml.cfm")>

      <cfset environment.use( identifier.currentEnvironment() )>

    <cfset APPLICATION.environment = this.environment>

   

    

</cffunction>

 

 

 

</cfcomponent>

 
Replies
  • Currently Being Moderated
    Jun 22, 2012 4:42 AM   in reply to nikos101

    Well you can debug it via a CFM file instead of from Flash (or using the CFB debugger, which I agree is a bit hit and miss.  Mostly miss).  And you could look at the error logs to see what the errors are...

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2012 5:57 AM   in reply to nikos101

    Right.  And what does the error message say:

     

    Element ENVIRONMENT is undefined in THIS. The specific sequence of files included or processed is: C:\Inetpub\wwwroot\coldfusion\tests\testEnvironmentName.cfm, line: 24

     

    Does that not give you a pretty big hint as to what's wrong?  Read the error, and ask youirself "OK, what does that mean?  What's CF telling me here?"

     

    It's also telling you the exact line that has the problem on it.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2012 6:08 AM   in reply to nikos101

    The only reference to this.environment is in that statement you just quoted.  So it doesn't exist.  Nowhere in your Application.cfc (as quoted in your earlier post) do you create that variables.  That's why CF is telling you it doesn't exist.  Because it dun't ;-)

     

    And - no - I could not get the CFB debugger working in any way other than very basic test cases (and ti wasn't very robust when I could get it working).  It seems you need to have your source code location, site structure and CFB project set up in a very unlikely-to-be-how-one-needs-it-to-be sort of way for it to work.  And I'm not going to restructure our application justt o get some shoddy CFB functionality to work.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2012 6:46 AM   in reply to nikos101

    Well you're not setting that either.  Why would you expect it to exist?  Do you understand that THIS.someVar != APPLICATION.someVar != someVar.  They are completely different things.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2012 7:42 AM   in reply to nikos101

    No.  The application scope is used to access application-scoped variables.

     

    I think you need to read up on how scopes work in CF.  Read this entire section of the docs:

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859 461172e0811cbec22c24-7ff2.html

     

    I can't guess where in your code you put the CFDUMP, so I can't really comment on the rest of it.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 22, 2012 8:24 AM   in reply to nikos101

    Yup!

     

    Make sure you read those docs though, eh?  It'll help clear up a lot of mysteries like this.

     

    --

    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 25, 2012 7:52 AM   in reply to nikos101

    I couldn't comment on how Flex calls might impact the presence of those variables.

     

    What do the error logs say?  They're likely to have more info.

     

    What other troubleshooting steps have you yourself come up with?  How have you tried to debug this?

     

    --
    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 26, 2012 3:40 AM   in reply to nikos101

    I'm trying to get Cf to know the location of the actual cfc I'm calling from flex but I can't get anything other than stuff like this:

     

    c:\\inetpub\\wwwroot\\flex2gateway

     

    How are you getting that?

     

    It'd be a lot easier to help you if you explain what you're doing (code) what the results are (as per above), and how that differs from your expectation.

     

    You could try getBaseTemplatePath().  This works for me when being called remotely from a browser, eg:

     

    <!--- Application.cfc --->

    <cfcomponent>

     

              <cffunction name="onApplicationStart">

                        <cfdump var="#getBaseTemplatePath()#">

                        <cfabort>

              </cffunction>

     

    </cfcomponent>

     

    <!--- C.cfc --->

    <cfcomponent>

     

              <cffunction name="f" access="remote">

                        <cfreturn "Hello World">

              </cffunction>

     

    </cfcomponent>

     

    Browsing to:

    http://www.scribble.local/cf/cfcs/app/whichFile/C.cfc?method=f

     

    I dunno if the contortions FLex goes to will mess with that, but what I see is:

     

    C:\WebSites\scribble\cf\cfcs\app\whichFile\C.cfc

     

    Which is correct.

     

    --

    Adam

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points