Apache – Display source code in a textarea component

apache-flexcoldfusion

I am putting together a presentation on flex for adobe user group that specialize in coldfusion. In my example I would like to display the text of the cfc being called from the webservice tag in my flex application. Is there a simple way to load the actual text for the cfc instead of the html that coldfusion is passing back to my URLloader variable?

Code that I have attempted to read the file:

    private function loadCodeTextAreas():void
    {
        codeURLLoader.load(new URLRequest("/FlexZenGardenCFC/GreetingService.cfc"));
        codeURLLoader.addEventListener(Event.COMPLETE,flexLoadCompleteHandler);
        codeURLLoader.addEventListener(IOErrorEvent.IO_ERROR,flexErrorHandler);
    }
    private function flexLoadCompleteHandler(e:Event):void
    {
        taCFCCode.text = codeURLLoader.data;
    }

Best Answer

You would have to call a CFC that would return the file read of another CFC. There is no way to ask ColdFusion to return its own code (for security reasons, etc). Something like this would work:

<cfcomponent>
<cffunction name="getFileContents" access="remote">
  <cfargument name="fileToReturn">
  <cfreturn fileRead( arguments.fileToReturn )>
</cffunction>
</cfcomponent>

Thats pretty rough code but should get you going.

Related Topic