User Guide

Table Of Contents
Calling Enterprise JavaBeans (EJBs) from Flash 129
mx.remoting.debug.NetDebug.initialize();
//…
function runExample()
{
var SampleLoanHome:Service = new Service(
"http://localhost:8300/flashservices/gateway",
null,
"SampleLoanEjbHome",
null,
null);
var pc:PendingCall = SampleLoanHome.create();
pc.responder = new RelayResponder(this, "create_Result", "create_Fault");
}
function create_Result( re:ResultEvent )
{
flashStatelessEJB = re.result;
calculate();
}
function create_Fault( fe:FaultEvent )
{
mx.remoting.debug.NetDebug.trace({level:"None", message:"There was a
problem" + fe.fault.faultstring});
}
function calculate()
{
var cal_pc:PendingCall = flashStatelessEJB.calculate( (number
(principalInput.text)), (number (monthsInput.text)), (number
(rateInput.text)) );
cal_pc.responder = new RelayResponder(this, "calculate_Result",
"calculate_Fault");
}
To handle the function results, you use a result handler function like the following:
function calculate_Result (re:ResultEvent)
{
payOutput.text = re.result;
}
function calculate_Fault( fe:FaultEvent )
{
mx.remoting.debug.NetDebug.trace({level:"None", message:"There was a
problem" + fe.fault.faultstring});
}
For more information, see “Handling function results in ActionScript” on page 137.
Looking at a Flash application that calls an EJB
The following sections illustrate the three pieces required to call an EJB from Flash Remoting:
“Looking at the EJB code” on page 130
“Looking at the user interface for the EJB” on page 130
“Looking at the ActionScript code that calls the EJB” on page 131