In my project, front end is created using Adobe AIR desktop application. Mainly back end is created using java and to integrate the java and AIR I have used BlazeDS technology.
In this article I am going to talk about how to create a simple application using Adobe AIR, java and BlazeDS using eclipse developing environment.
To develop the flex application using eclipse required to installed the flex plugins for the eclipse. also required to install the Adobe AIR runtime environment. you can download it from http://get.adobe.com/air/?promoid=BUIGQ
For the blazeds communication we required to have java server so I am going to have a tomcat server for my java server. Configuration 1) extract the downloaded blaseds.war in to folder blazeds. 2) put that blazeds folder in to C:\apache-tomcat-6.0.29\webapps. in here I have my tomcat server in C:\
let's create Hello world application for AIR, java and blazeds I am going to create AIR project first. Here I am using Eclipse.
1). open new and navigate to 'flex project' as the above you have to select Application type as Desktop Application and Application server type as J2EE. also required to check the check box and select LiveCycle Data Services radio button and click Next.
2). In there need to give Root Folder by browsing to C:\apache-tomcat-6.0.29\webapps\blazeds Root url - http://localhost:8080/blazeds
Context root - /blazeds output folder - C:\apache-tomcat-6.0.29\weba pps\blazeds\hello-debug after that you can create simple hello world application using AIR.
{ var cs:ChannelSet = new ChannelSet(); var customChannel:Channel = new AMFChannel("my-amf", "http://localhost:8080/blazeds/messagebroker/amf"); cs.addChannel(customChannel); srv.channelSet = cs; } //fault of conversion private function faultHandler(event:FaultEvent):void { Alert.show( ObjectUtil.toString(event.fault) ); } //success of conversion private function resultHandler(event:ResultEvent):void { Alert.show( ObjectUtil.toString(event.result) ); }
private function send():void { var input:String = input.text;
in the above air application get the name from the user and when user click on the hello button application send the name to java side through the blazeds.
java class can be shown as bellow,
public class hello { public String sendData(String name){ String result=""; result = name; return result; } } it is a simple java class that take the name receiving from AIR side and send it back. To integrate both of java and AIR we need to create another java class called connector. That can be shown as bellow,'
public class connector { public String send(String name){ String result=""; hello ob=new hello(); result=ob.sendData(name); return result; }
}
after that need to run both java classes and put there class files into C:\apache-tomcat-6.0.29\webapps\blazeds\WEB-INF\classes
after that change the remoting-config file in flex folder C:\apache-tomcat-6.0.29\webapps\blazeds\WEB-INF\flex as bellow,
after did all the things start up the tomcat server and you can view your AIR application. Give the name as text input and click hello button and you can see the alert box saying your name.
No comments:
Post a Comment