Adobe COLDFUSION 9 Manual page 660

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

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Flex and AIR Integration in ColdFusion
Attribute
Description
cfContextRoot
The context root if any for the CF server.
secureHTTP
Boolean value specifying whether to use http or https to run the service.
destination
The destination attribute can be used to specify a user defined remoting destination in WEB-INF/flex/remoting-
config.xml. If not specified, default ColdFusion destination is used.
You normally specify the config class using an MXML tag as follows:
<cf:Config id="conf" cfServer="CF Server IP Address/HostName" CFPort="HTTP Port on Which CF
accepts request" destination="UserDefinedRemotingDestination" >
You can also override the server settings directly in the service tag, for example:
<cf:Image id="image" action="AddBorder" cfServer="IP Address" cfPort="Port number"
source="Uploaded Image server URL" thickness="5" color="Blue"
destination="UserDefinedRemotingDestination" />
Using the Util class
The Image, PDF, and Mail services typically act on a file that has been uploaded to the server. To upload the file to your
CF server, use the Util class to run the ColdFusion Upload service. The Util class consists of two elements:
• The
constant contains the URL on the ColdFusion server of the Upload service, relative to cf_webroot.
UPLOAD_URL
• The
extractURLFromUploadResponse()
returns the path of the uploaded file on the ColdFusion server.
You use the
constant and the
UPLOAD_URL
to upload a file and use the file in a ColdFusion service.
Event flow of the ColdFusion service
1
Use the ActionScript
flash.net.FileReference
PDF, or mail attachment to the server on which the action has to be performed. The upload URL to supply to the
flash.net.FileReference
uploadURL.url =
"http://"+conf.cfServer+":"+conf.cfPort+"/"+conf.contextRoot+"/"+Util.UPLOAD_URL;
var variables:URLVariables = new URLVariables();
variables.serviceusername = conf.serviceUserName;
variables.servicepassword = conf.servicePassword;
uploadURL.data = variables;
uploadURL.method="POST";
Here, specify "conf.cfServer", "conf.cfPort" and "conf.ContextRoot" in the <cf:Config> tag. Specify
"conf.ContextRoot" only if ColdFusion is deployed as a J2EE application.
Note: The ActionScript FileUpload functionality is out of the scope for this feature hence it is not explained in detail,
but an example of the usage is provided in code in MAIL class section. For further information on FileUpload
functionality see the ActionScript documentation.
Once the file is uploaded, the server returns an XML response containing URL of the uploaded file. Use the Util
2
class function
extractURLFromUploadResponse()
Use the file URL in the source attribute of the service tags.
3
4
When the required service tag attributes are set, run the service action by calling the following method:
method takes response returned by the Upload service as input and
extractURLFromUploadResponse()
APIs and the
APIs can be constructed as follows in the ActionScript part of the application:
to extract the URL from the XML
Last updated 8/5/2010
function in the following workflow
variable to upload an Image,
Util.UPLOAD_URL
655

Advertisement

Table of Contents
loading

Table of Contents