Calling Enterprise JavaBeans (EJBs) from Flash
131
Looking at the ActionScript code that calls the EJB
The following code is the ActionScript of the example Flash application:
// Import Flash Remoting files
import mx.remoting.Service;
import mx.remoting.debug.NetDebug
// --------------------------------------------------
// Start up the application
// --------------------------------------------------
function ejbLoan_init(){
flashstatelessHome = new Service(
"http://localhost/flashservices/gateway",
null,
"SampleLoanEJBHome",
null,
null);
pc:PendingCall = flashstatelessHome.create();
pc.responder = new RelayResponder(this, "create_Result", "create_Fault");
}
// ---------------------------------------------------
// Business Methods
// ---------------------------------------------------
// Calculate payment based on data user enters in principalInput,
// monthsInput, and rateInput text fields. Function arguments must
// be numbers. Java method expects double, int, and float.
function calculate()
{
flashStatelessEJB.calculate( (number (principalInput.text)),
(number (monthsInput.text)), (number (rateInput.text)) );
}
// --------------------------------------------------
// Handlers for data coming in from server
// --------------------------------------------------
// Get reference to EJBObject and invoke calculatePayment function.
function create_Result( result:ResultEvent ):Void
{
flashStatelessEJB = result;
calculate();
}
// Get reference to calculate result object and display result
// in PayOutput text field.
function calculate_Result (result:ResultEvent):Void
{
payOutput.text = result;
}