aspose file tools*
The moose likes Flex and the fly likes Can Flex communicate with Java based backend? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "Can Flex communicate with Java based backend?" Watch "Can Flex communicate with Java based backend?" New topic
Author

Can Flex communicate with Java based backend?

Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
HI, I have never used a Flex/Flash, as a frontend, and I have no idea how they function. However, I was wondering does Flex can communicate with Java backend (example: I have some Java based web app. in backed, Servlets, EJB3, Web Services, or whatever) ? Does Flex send a request, which can be handled as a HttpServletRequest, from the Servlet?
So can I just create some Flex application, which can communicate with existing backed, if I wanted to replace my HTML/Css/JQuery fronted with Flex?
Brick Riccardi
Greenhorn

Joined: Jun 01, 2008
Posts: 22
Slobodan Erakovic wrote: However, I was wondering does Flex can communicate with Java backend (example: I have some Java based web app. in backed, Servlets, EJB3, Web Services, or whatever) ? Does Flex send a request, which can be handled as a HttpServletRequest, from the Servlet?


Yes very easily. You can use BlazeDS or I still prefer just using the HttpService object to send and HttpRequest and return XML from my servlet (technically I'm returning it from Stripes ActionBeans on the midtier, but it's ultimately just a servlet under the hood.)

Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Does that mean, some kind of "wrapping" data sent from Flex, or just as I do in servlets/jsp, specify name of servlet in action attribute, and just handle the request on server side?
Or can you just give an example of that, if you do not mind (just a few lines of code, sending request from Flex, and their managing on server).
Thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Slobodan Erakovic wrote:Does that mean, some kind of "wrapping" data sent from Flex, or just as I do in servlets/jsp, specify name of servlet in action attribute, and just handle the request on server side?
Or can you just give an example of that, if you do not mind (just a few lines of code, sending request from Flex, and their managing on server).
Thanks

No, no special wrapping its just what any HTTP request does. BlazeDS uses a binary format in its HTTP requests, but they are still HTTP requests nonetheless.

The RemoteObject documentation has a bunch of examples.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Yes, I saw. But there are EJB 2 examples,but doesn't matter. I am in doubt between JavaFX and Flex, that is why I asking for. In JavaFX, the only thing I need to know is JavaFX Script itself. That is all, because everything else I either know.or I am familiar with. It perfectly communicate with Java entirely.
In Flex, as much as I figure out I need to learn ActionScript, then MXML, and then that framework you have mentioned BlazeDS.
It is kind of three new areas, in order to successfully use (merge) my knowledge of Java (specifically in backend), with frontend, if I choose Flex, or I am wrong about my consideration about Flex?
Any advice, architectural direction?
Brick Riccardi
Greenhorn

Joined: Jun 01, 2008
Posts: 22
Slobodan Erakovic wrote:
It is kind of three new areas, in order to successfully use (merge) my knowledge of Java (specifically in backend), with frontend, if I choose Flex, or I am wrong about my consideration about Flex?
Any advice, architectural direction?


Well the backend server side I'd create TOTALLY without regard for the front end (well other than the fact that for every server side class, I also have a matching method that returns XML.) But other than that UI front end doesn't matter.

I'm a java guy myself but haven't messed with JavaFX. I just don't want to bother with it, because I doubt it's going to be a major player (I could be wrong though, but I just don't see it.) If you are going to learn a new front end UI technology I'd still stick with Flex/AS or even Silverlight over JavaFX, but that's just me. By the way if you know Java, then ActionScript is a breeze - the learning curve for me was just learning how to deal properly with Events and asynch operations properly. (RobotLegs made my job a lot easier there. For a good UI example.. I HIGHLY recommend Joel's AddressBook example app http://github.com/joelhooks/robotlegs-examples-AddressBook - It's awesome. Thanks Joel

I'll probably create a tutorial soon myself (actually in June when done with this project) that demonstrates an Employee CRUD app written with Flex (RobotLegs) on the front-end hooked into Stripes/Groovy/iBATIS on the java side. (I've written some other ones for other technologies here so it will be similar .)
Goran Markovic
Ranch Hand

Joined: Sep 26, 2008
Posts: 399
Can you give me an advice, about some good book for this Java guy, in order to comprehend a Flex (including all technologies I need to know about, in order to master Flex) in more flexible and quick way?
I mean, do I need to use "ActionScript in action", "Flex in action" and "MXML in action", separately to learn, or I could choose some book of learning Flex, which I guess comprehend all of these technologies, I should know for building nice UI?
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can Flex communicate with Java based backend?