June 2010 Update: This original blog post was written prior to the release of Spring Flex Scaffolding support in MyEclipse for Spring 8.6. Wanna build an entire Spring Flex CRUD app using your tables or code in a matter of seconds?  This tutorial is now productized in the MyEclipse for Spring 8.6 release.  Download and try it today! Check out the what’s generated blog or the getting started video.
Body builder competition Flex application

This blog/tutorial covers the basics to getting started with spring-flex development in Skyway.  The spring-flex framework uses Adobe’s open source BlazeDS project, which is the remoting and messaging foundation for connecting a Flex-based front-end to Java back-end services.  Skyway is used to accelerate the Spring development by providing a visual environment to generate all the necessary Spring configuration files and CRUD operations in a SpringSource certified Spring MVC application.  The tutorial then goes on to tweak the Skyway generated configuration files to support Flex Remoting to produce the list view above that calls the Skyway generated Spring service.

This blog is divided into 2 parts:

What you’ll need first

Before creating the project, there are a handful of items you’ll need to setup your Skyway Flex Builder environment.

  1. Download BlazeDS: I downloaded the BlazeDS turnkey ready-to-use distribution, which comes with a version of tomcat.  The BlazeDS installation guide was very helpful after the download.
  2. Get FlexBuilder: You’ll need something to compile your mxml into swf.  There’s a 60 day trial of FlexBuilder 3.  IMPORTANT: per M. Zach’s comments, it is essential to download Eclipse Ganymede (3.4 – for Java Developers) first, then install the FlexBuilder 3 plug-ins on top of that install, and finally install the Skyway Builder plug-ins.
  3. Get Skyway: Install the Skyway plug-ins on top of the FlexBuilder Eclipse instance. Download the Community Edition, or test drive the full featured Commercial Edition.
  4. Server & DB: Create your server and datasource connections inside Eclipse.  If you need help, Skyway has a sandbox setup guide that can help.  Point the server to the BlazeDS tomcat installation.
  5. References: Have the references section at the end of this blog handy.  They are great resources for deeper understanding on any topic discussed here.

Create the Project & CRUD

There are several ways to create a Flex Project with Skyway’s generation capabilities.  If you have an existing Flex Project, follow the recipe on setting up and Eclipse Dynamic Web Project.  For new projects, the cleanest way I found to set up the project is to create a Skyway Project and then add the Flex Nature described here:

  1. New Skyway Project: File > New > Skyway Project.  Name it BodyBuilder. Accept all defaults and click Finish.
  2. Add Flex Nature: Right-click the created BodyBuilder-Web project, and select Flex Project Nature > Add Flex Project Nature.  Modify the defaults as described in the following:
    1. Application server type: J2EE
    2. Use remote object access service: Checked
    3. LifeCycle Data Services: Enabled
    4. Click Next
    5. Flex WAR file: <Blazeds installation>\blazeds.war
    6. Click Finish.

  3. Clean up the Errors: You may get some errors in the Problems tab after adding the Flex Nature (also see M. Zach’s comments below):
    1. Server SDK: Directory does not contain a Flex SDK.  To resolve, right-click the Web project > Properties > Flex Compiler.  Choose Use default SDK in the Flex SDK version. This will then create another error about Cannot create HTML wrapper.  Just follow the instructions in the error:right-click and choose Recreate HTML Templates.
    2. Web library project archive commons-codec-1.3.jar conflicts with another archive also mapped to the WEB-INF/lib folder: This is due to Skyway’s default library classpath container management.  The easiest way to resolve is to go to the Web Project > WebContent/WEB-INF/lib folder and delete all the jars that do NOT start with flex-*.
  4. Create the Domain Object: This is the start of CRUD Scaffolding.  If you aren’t familiar with Skyway’s CRUD Scaffolding capabilities, please take a look at the short How To on CRUD App Scaffolding for more details.
    1. Right-click the Spring DSL artifact under the BodyBuilder project, and select New > Model Package.  Name it com.bodybuilder.domain.
    2. Right-click that Model Package, and select New > Domain Object.  Name it Contestant. Add any fields to the Contestant Domain Object, making sure a primary key is specified.  It may look something like the following image (click to enlarge):contestant-do
    3. Scaffold CRUD: With a few short clicks, all the necessary Java and Spring MVC artifacts will be generated to support Create, Read, Update, and Delete operations on this domain object.  Right-click the Contestant visual Domain Object, and select Scaffolding > Scaffold CRUD.

Add Spring Flex

Covered in Part 2 of 2

Page 1 | 2 | >

Bookmark and Share

Tags: , , , , , ,

{ 5 Comments }
  1. Accelerate Spring Flex development with Skyway + BlazeDS (Part 2/2) - Skyway Team Blog says:

    [...] Spring Flex development with Skyway + BlazeDS (Part 2/2) by Dave on December 17, 2009 In Part 1 of Accelerate Spring Flex development with Skyway + BlazeDS, I covered prerequisites, development [...]

  2. M. Zach says:

    Hi Dave,

    first of all thank you for setting up this tutorial. I can imagine that is not easy to find a way for the very first time. So thank you for your tutorial!

    I followed your instructions, here are my comments:

    Perhaps it helps to mention, that it does not work to install Skywaybuilder Plugin on Flexbuilder, nor to install Flexbuilderplugin on Skywaybuilder due to the changed folder structure.
    So its essential to install Eclipse Java EE first, then the Flexbuilder Plugin and then the Skywaybuilder Plugin.

    Then for the point “Add Flex Project nature” its not enough to accept the default (after a clean install) you have to
    - select “J2EE” Server under ServerType and
    - check the checkbox under “use remote object access service” and
    - choose “LiveCycle Data Services” and click next:
    - configure the location of the Flex War File by browsing for example to C:\web\bin\blazeds\blazeds.war.

    Under Part I 3. Clean up the Errors it would be easier to change all settings in one step as follows

    Flex Compiler: Choose to use default SDK Version

    If using the turnkey version which uses port 8400 the following changes have to be made:
    Flex Build Path: (this is missing)
    Change Output folder to http://localhost:8400/BodyBuilder-Web
    Flex Server:
    Change Root URL to “http://localhost:8400/BodyBuilder-Web”
    change Contect root to “/BodyBuilder-Web”

    Under 3.2. it enough to delete the “Common codecs”

    For a Flex developper it would be esier to mention, that after CRUD scaffolding
    - to click on the generated “ContestantDAO”
    - click on “Database Configuration” and choose the desired Database Connection
    - hit save and click on “BodyBuilder Web” and “Run as”/ “Run on Server” to check if everything is ok so far.

    Hope this will help somenone.

    Cheers!
    M. Zach

  3. Israel says:

    Thanks for the extra details M. Zach, i was unable to use this blog- post until i found the extradetails you kindly added… :-)

  4. Niel Eyde says:

    Thank you Isreal and M. Zack. Dave (the author of this blog post) is on vacation this week, but he’ll take a look at the instructions when he returns. We’ll update whatever needs to be updated.

    There’s also a forums thread on the Skyway Builder forums where the integration with Flex is being discussed.
    http://www.skywayperspectives.org/portal/web/guest/174/message_boards/message/75376

  5. Dave says:

    M. Zack, thank you for the comments!! I will update my blog with your updates.

Leave a Reply