Adobe COLDFUSION 9 Manual page 273

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Developing CFML Applications
Example
The following code describes how to write an image as an in-memory file:
<cffile action="readBinary" variable="myImage" file="#ExpandPath('./')#/blue.jpg">
<cffile action="write" output="#myImage#" file="ram:///a.jpg">
<cfif FileExists("ram:///a.jpg")>
<cfoutput>a.jpg exists</cfoutput>
<cfelse>
<cfoutput>a.jpg Doesn't exists</cfoutput>
</cfif>
Writing and instantiating dynamic CFC files
The following syntax explains how you can write CFC code in to an in-memory file:
<cffile action="write" output="#cfcData#"
file="ram:///filename.cfc"/>
The following sample syntax explains how you can instantiate the in-memory CFC file:
<cfset cfc=CreateObject("component","inmemory.filename")/>
Here,
is the ColdFusion mapping that points to
inmemory
Note: You cannot have Application.cfc as an in-memory file. If you have one, it is ignored.
Example
The following code writes a CFC as in-memory file:
<cffile action="read" file="#ExpandPath('./')#/dynamic.cfc" variable="Message">
<cffile action="write" file="ram:///cfc/dynamic.cfc" output="#Message#">
To invoke a component method:
<cfinvoke component="inmemory.cfc.dynamic" method ="method1" returnVariable="returnVariable">
<cfinvokeargument name="paramOne" value="hello">
</cfinvoke>
<cfoutput>#returnVariable#</cfoutput>
Working with in-memory file system
The following sections provide information that can help you to access and use in-memory files.
Using in-memory files
• You can call a CFC saved on RAM from a CFM file on disk. Similarly, an in-memory CFM file can call a CFC saved
on disk.
• If a CFC extends another CFC in the same directory in RAM, you can use relative path. For instance, if a.cfc and
b.cfc belong to the same directory in RAM, a.cfc can extend b.cfc using relative path as shown in the following code:
<cfcomponent name="a" extends"b">
...
</cfcomponent>
• You can use in-memory ColdFusion interfaces in the same way as you use in-memory CFCs.
ram:///.
Last updated 8/5/2010
268

Advertisement

Table of Contents
loading

Table of Contents