Monday, June 21, 2010

InfoQ: Building Web and Desktop Applications with BlazeDS and AMF

You will need the following software installed:

To create a simple Remoting Application:

  1. Unjar the blazeds.war file from BlazeDS into your application server's deployment folder. For instance, on JBoss use /server/default/deploy/blazeds.war
  2. Start Eclipse / Flex Builder
  3. Create a new Java Project that you can use to configure BlazeDS and add Java classes to your web application.
    1. Use a project name like "blazeds_server"
    2. Create the project from existing source; use the path of the WEB-INF directory of your deployed BlazeDS WAR, such as: /server/default/deploy/blazeds.war/WEB-INF/
    3. Add the src directory to the build path
    4. Use the WEB-INF/classes directory as the output folder
  4. Create a new Java class called HelloWorld.java with the following code:
  5. public class HelloWorld {
    public String sayHello(String name) {
    return "hello, " + name;
    }
    }
  6. Configure BlazeDS to allow remoting requests to the HelloWorld class by adding a destination to the remoting-config.xml file found in the WEB-INF/flex directory. Use the following destination configuration:


  7. HelloWorld

  8. Start your application server and verify your web application is configured by going to the following URL (The port may vary depending on your application server configuration): http://localhost:8080/blazeds/
    (If your server is not configured to display directory contents, you might see a 404 error. This is OK.)
  9. Create a new Flex Project
    1. For the project name, type "testHelloWorld"
    2. Select "J2EE" as the Application Server Type
    3. Select "Use remote object access service" and LiveCycle Data Services
    4. Specify the Root folder to be to location of your deployed WAR file
    5. Specify the Root URL to be: http://localhost:8080/blazeds (Your port name may be different depending on your application server configuration)
    6. Specify the Context Root to be: /blazeds
    7. Verify the configuration and click Finish
  10. Create the Flex application by updating the testHelloWorld.mxml file with the following source code:





  11. Run the application and test it by typing your name into the TextInput box. You should see "hello, " displayed beneath the TextInput like the image below.
More info at:
InfoQ: Building Web and Desktop Applications with BlazeDS and AMF

No comments:

Freelance