Spring Flex3 Quick Integration
Step By Step:
1) Create New Dynamic Web Application:
2) Right click on the new created application, go to Flex Project Nature > Add Flex Project Nature
Choose the J2EE Application server Type. Then check the “use remote object access service” and keep LCDS selected. It’s not really LCDS, but its Open Source version (BlazeDs).
3) Click Next, Browse, Navigate to the blazeds.war:
then click Finish.
5) Go to project properties > Flex Server > Context Root and change the “/WebContent” to “/[YourProjectName]”
6) Go to the WebContent/WEB-INF, add a directory(config) and create an xml file (webApplicationContext.xml)
9) Now, unzip the spring integration with dependencies files and copy all the jars into your lib directory. You’ll find some double version jars, so just choose the newest.
10) Add a java entity to your src dir. In this project, we start with a small sample class “Document”:
and then create a database table called Document with three fields (id:Integer,type:varchar(20), title:varchar(50));
That’s all with Spring and hibernate code. we need just to add those entities to our configuration file:
add the annotated class to your session factory:
12)Now move to the Flex part and create the corresponding AS3(ActionScript 3) entity to your Java ‘Document’ class.
Note the meta-tag RemoteClass that describes the corresponding class on the Java side. It’s crucial to keep the same names of attributes, but don’t care that much about the scope (private/public/…) of the AS class attribute.
and then declare the mx:RemoteObject and some code for insert operation: