Flex 3.0 Applications with BlazeDS in Eclipse

February 16, 2009

Adobe Flex, Eclipse

«»

Creating RPC Service

The Remoting service is one of the RPC Service included in BlazeDS. Through this service client applications can talk to Java POJO’s on the server side.

First we will start with an server POJO implementation. So we will write a Java class which will return the entered name appended with Hello.

1. In the Flex Navigator of the IDE, Expand the project node and go to ‘src’ folder.

2. Right click on ‘src’ folder. Click on ‘New’ and go to ‘Other’ menu item and click on that item. (src > New > Other).

3. The selection wizard opens up. Select ‘Java’ node and select ‘Class’ as shown below.

4. Create a new Java class by name as ‘FlexBeat’ inside the package ‘net.java.beat’

5. Write a method to accept a input string as a parameter and returns a string back appending with Hello to the input string. The Java code is given below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package net.java.beat;
 
/**
* @author Sri hari
* 
*/
public class FlexBeat {
/**
* This method accepts a name and returns a string appending with Hello.
* 
* @param yourName
* @return
*/
public String sayHello(String yourName) {
return "Hello " + yourName;
}
}

Configuring Remote Object Service

1. In the Flex Navigator goto WebContent > WEB-INF > flex > remoting-config.xml and open it in the source editor of IDE.

2. Change the configuration file as below.

3. Change the services-config.xml file located. Here we have to change the channel-defenition end points to use tomcats port, host and context. Change it as shown below. This ends the configuration part of Remote Object Service.

Creating the Client application MXML file

The Flex client application uses the Remote Object component to access the Java POJO method, For doing so client application uses the destination property to specify the destination. see the client code below.

In the above code Flex application uses the RemoteObject tag to invoke the Java POJO’s.

Enter the same code shown above in the source editor. This code is saved as FlexBeat.mxml. Once the file is saved then clean and build the web application.

email

«»

Comments

comments

, ,