views:

1444

answers:

5

In a Flex / Java app stack using remoting (via BlazeDS), classes to hold data passed back and forth between client and server need to be maintained in both the client (in ActionScript) and server (in Java).

I want a way to maintain theses classes in Java only, and have the corresponding ActionScript value object classes generated by the build process.

A: 

XDoclet2 includes an ActionScript plugin that can generate ActionScript classes from Javadoc comments in Java code.

The downside is that it's based on Javadoc rather than Java annotations, and does not appear to be well-documented or very widely used.

eli
Agreed. I tried to get into this stuff and abandon it in the end.
Stu Thompson
A: 

There are a couple of free Java to AS3 converters out there of varying quality:

I cannot vouch for their quality but they claim to do what you are looking for.

Personally I take the overhead of maintaining the two code bases manually because once the objects settle there is not much to do and it means I don't have complex rules around the rest of the code which is in the objects.

Plus my Java objects all have getters and setters whereas the AS3 equivalents do not, which means the public/private accessors are different in any case.

HTH

Simon
The download link on the j2as3 site appears to be broken.
eli
+1  A: 

Check out the AS3 generator from the Granite Data Services project:

http://www.graniteds.org

If I recall correctly it's an Eclipse plugin which should be quite easy to use. Just remember that if you exclude a property from the ActionScript class that it will still be serialized by Blaze when it's sent back to the Flex client.

cliff.meyers
A: 

If you're going to be doing a Flex RIA app of any degree of sophistication, then you'll probably be implementing the MVC pattern - ala Cairngorm, Mate, or PureMVC.

Take a look at this Flex code generator as it anticipates your use of MVC in the Flex client and generates code suitably to deliver an even higher degree of leverage:

FCG : a Flex Code Generator

RogerV
A: 

Hi,

help me in improving this Java to AS Converter

http://ranjitfx.wordpress.com/2010/03/25/convertcreate-java-dto-to-action-script-as-equivalent-remote-class/

Ranjit