Now we’ve got Adobe Flex configured to work with BlazeDS let’s start with our first project.
We will do this:
We will create the front-end logic in Actionscript and MXML.
We will create the back-end logic in JAVA
We will create the needed config files to establish a bridge or a connection between the front-end and the back-end.
So let’s start creating a new project, this time we want to use a Server technology. Here we must select J2EE because tomcat / BlazeDS uses this language / technology and we won’t touch anything
you can see the results in the next image:
At the bottom of the image you’ll see a check box with this text: Create combined Java / Flex project using WTP. In the java source folder will be placed all the raw java files, the logic of the back-end, once you execute the project this logic will be compiled and placed to the server automatically, don’t worry about that.
Next we must configure the J2EE settings, the target runtime will be BlazeDS we created in the last post. I always put the same in the Context root and the Content folder, the project name, but in this example I will put context_root and content_folder to show you how the folders and files are created. The project is structured like this:
Inside the content_folder to folders has been created: META-INF, and WEB-INF ( this is the important one now… )
inside WEB-INF we’ve got 4 folders:
classes: This is the back-end compiled logic created inside the src folder, every time you run the project the JAVA files will be recompiled ( if needed ) and updated inside this folder.
flex: Here is the messaging configuration you will see 4 files inside this folder but you only need services-config.xml the other files are automatically created for order purposes, if you delete them you will get some errors because you must edit services-config.xml. This file includes the other three, if you delete this inclusions, you can delete the files… ( of course this files are useful to mantain the messaging structure clean but this is a beginner tutorial!! )
lib: Some libraries, don’t need to look here…
src: Don’t need to look here either…
web.xml configuration file, we won’t edit this.
OK.
Now we’ve got our structure created the first thing we must do is add our project to our server, this will create a new folder inside the backend with the name of the project and this will contain a copy of our recently created content_folder.
Now we will delete all the files inside content_folder -> WEB-INF -> flex except for services-config.xml, and we will edit the services node like this:
com.ncatstudios.remoting.Test
The important parts of this piece of XML are the destination and the source. The destination is like the address of the wharehouse where to fetch the data. We must call somewhere from flex to access the data, this name must be the same both sides. The source is the name of the JAVA class ( package doted format ) where we will call the methods.
Finally here is the code to run the application:
and the JAVA logic:
package com.ncatstudios.remoting;
public class Test {
public String sayHelloTo(String who)
{
return "Hello " + who;
}
}
Now you can run the application to test it.
Possible error / bug: I found that sometimes my application doesn’t run as it should.
If you open the project properties, inside the Flex Server section just delete the folder of the root URL, leave it to http://localhost:8080, you probably won’t need to edit this for rest of the life of this project.
Related posts:
- Setting up your BlazeDS (tomcat) server on Eclipse ( local )
- Flex & Drupal login ( Actionscript remoteObjects )






It‘s quite in here! Why not leave a response?