Java – Question about integrating java and flex

apache-flexjava

I have a flex web app and want to integrate it with Java.

The app will have a very small database (2-3 tables), and some routine logic like sending mail.

According to this link (http://learn.adobe.com/wiki/display/Flex/2b.+Code+Files), I would need to also have a .jsp file. I thought Flex would only be interested in my classes?

Also, my java method would take parameters – how can I pass the values in the textboxes of a flex .mxml page to the java method? A simple example would really help me.

When using httpservice calls, is there anything else I need to know?

Thanks

Best Answer

Check out Blaze DS. It's pretty simple to set this up so that you can invoke methods on your Java classes from Flex.

http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/

Basically you register a RemoteObject that references the URL of your Flash Remoting endpoint and specifies the destination (usually the class name). Consult the WebOrb docs on how to do that. Once that's done, you can just invoke the RemoteObject like so:

var token : AsyncToken = emailService.sendEmail(subject, body); token.addResponder(responderImpl);

You create an implementation of the IResponder interface and register it against the "AsyncToken" which is returned from remoting calls in Flex. All calls to the server in Flex are asynchronous which is why you register a responder which then has either the result or fault method invoked.