MACROMEDIA COLDFUSION MX 7.0.2-USING COLDFUSION MX WITH FLEX 2 Guida Utente Pagina 248

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 256
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 247
248 Use ColdFusion Event Gateway Adapter
Send a message to ColdFusion
In this section, you create a function to send a message through the Flex Messaging event
gateway to a ColdFusion application. You then create a structure, named msg, that contains
the gateway ID, and the information necessary to send an e-mail message. The gateway ID is
the ID you assign when you create the gateway instance in ColdFusion MX Administrator.
Finally, you send the message to ColdFusion.
1. Directly below the initApp method, add the following code:
public function sendMessage():void {
var msg:AsyncMessage = new AsyncMessage();
msg.headers.gatewayid = "Flex2CF2";
msg.body = new Object();
msg.body.emailto = emailto.text;
msg.body.emailfrom = emailfrom.text;
msg.body.emailsubject = emailsubject.text;
msg.body.emailmessage = emailmessage.text;
pro.send(msg);
messagestatus.text = "Message sent to ColdFusion.";
}
2.
Save the file.
Receive a message from ColdFusion
In this section, you display a message sent from ColdFusion.
1. Add the following function after the sendMessage function:
private function messageHandler(event:MessageEvent):void {
messagestatus.text = "Message received from ColdFusion";
}
2.
Save the file as flexemail2cf.mxml. in the
C:\fds2\jrun4\servers\default\samples\dataservice\maypp folder.
Verify that your code is correct
Your code should match the following code example. Verify that the content is correct.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="initApp()">
<mx:Script>
Vedere la pagina 247

Commenti su questo manuale

Nessun commento