the way I have done similar things avoids code duplication. Basically you use the HTTPService or URLRequest classes to make the necessary calls into your Java server pages (you can use either post or get) and use the Flex event handlers to parse the response and do whatever you want. The JSPs you call should turn the Java response into some suitable format - I typically use XML - to structure the response, then the client side interpretation of that should be easy. The server is responsible for generating the answers from database calls or other manipulation, and the client is responsible for binding the responses onto suitable interface elements.
If you already had written some client side display stuff directly into JSPs, then yes those parts of your code will need updating, but ideally your display needs and your back-end logic are already separated to a good degree so the "upgrade" will not be too painful.
Thanks for prompt reply. Yes you are right about HttpService but in my case it has two issues;
- It returns data in XML format while all of my methods returns domain objects collections and chaning these to produce XML is not feasible
- For using HTTPService i need Servlet/JSP pages to invoke. However for frameworks like Tapestry that has only HTML pages this is not possible
HTTPService can call HTML pages, so maybe Tapestry would work?
Have you considered using JSON to format the object data?
These lins describe using JSON and Flex:
If this post answers your question or helps, please mark it as such.
Consider using BlazeDS (http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/) You configure this into your servlet container as a servlet handler for a specific path. BlazeDS will know take care to convert between a java class and a properly mapped actionscript class. If you think duplicating classes in as and java is too much, look into a Gas3 (http://www.graniteds.org/confluence/display/DOC/2.+Gas3+Code+Generator) it offers AS3 code generation from Java beans to AS3 as a plugin to eclipse and an ant task. Alternatively, you can simply let BlazeDS convert your beans into generic AS3 objects. For example, a java bean will have all its methods called and converted to an AS3 Object of class Object with the values from those setters as properties of the object.