总结一
下flex+BlazeDS整合j2ee开发环境的配置过程:
1.从http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/ 下载BlazeDS
2.新建一个web project 名为:flexDemo
3.解压BlazeDS.war到%TOMCAT_HOME%/webapps目录下文件名为blazeds内包涵了WEB-INF和META-INF文件夹
4.在flexDemo/src目录下新建类HelloWorld
- package cn.riahome.java;
-
-
- public class HelloWorld {
-
- public HelloWorld() {
- }
-
- public String getHelloWorld(String name) {
- return "Hello World!"+name;
- }
- }
package cn.riahome.java;
/**
* <p>功能:</p>
* <p>生成日期: 2008-10-13</p>
* <p>说明:</p>
* @author lipei_ma
* @version V1.0
* @修改日志:
*/
public class HelloWorld {
public HelloWorld() {
}
public String getHelloWorld(String name) {
return "Hello World!"+name;
}
}
5.部署 应用flexDemo到Tomcat服务器中,并启动服务。
6.为flexDemo添加blazeds支持: 将%TOMCAT_HOME%/webapps/BlazeDS/WEB-INF/lib目录下面所有jar文件拷贝到 flexDemo 的webRoot/WEB-
INF/lib 目录下. 将%TOMCAT_HOME%/webapps/blazeds/WEB-INF/flex 目录拷贝到Demo的webContent/WEB-INF 下. 拷贝%TOMCAT_HOME%/webapps
/BlazeDS/WEB-INF/ 下的web.xml覆盖flexDemo的 web.xml ,至此,我们的Demo已经具备了blazeds 的功能.
7.为项目增加Flex支持,右键项目名称,点击Flex Project Nature/Add Flex Project Nature
8.编辑flexDemo.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
- <mx:RemoteObject id="say" destination="helloWorld">
- </mx:RemoteObject>
- <mx:Button x="335" y="80" label=" Click" click="remotingSayHello(event);"/>
- <mx:TextInput x="159" y="80" id="tiName"/>
- <mx:Label x="109" y="82" text="name:"/>
- <mx:Label text="{say.getHelloWorld.lastResult}" x="44" y="162" width="448" height="71" id="lblView" color="#FCEE09"
-
- fontSize="20" fontWeight="bold" textDecoration="underline" fontStyle="normal"/>
- <mx:Script>
- <![CDATA[
- public function remotingSayHello(event:Event):void{
- var iname:String=tiName.text;
- say.getHelloWorld(iname);
- }
- ]]>
- </mx:Script>
- </mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:RemoteObject id="say" destination="helloWorld">
</mx:RemoteObject>
<mx:Button x="335" y="80" label=" Click" click="remotingSayHello(event);"/>
<mx:TextInput x="159" y="80" id="tiName"/>
<mx:Label x="109" y="82" text="name:"/>
<mx:Label text="{say.getHelloWorld.lastResult}" x="44" y="162" width="448" height="71" id="lblView" color="#FCEE09"
fontSize="20" fontWeight="bold" textDecoration="underline" fontStyle="normal"/>
<mx:Script>
<![CDATA[
public function remotingSayHello(event:Event):void{
var iname:String=tiName.text;
say.getHelloWorld(iname);
}
]]>
</mx:Script>
</mx:Application>
编辑WEB-INF/flex/remoting-config.xml文件
- <destination id="helloWorld">
- lt;properties>
- <source>cn.riahome.java.HelloWorld</source>
- lt;/properties>
- </destination>
<destination id="helloWorld">
<properties>
<source>cn.riahome.java.HelloWorld</source>
</properties>
</destination>
9.右键项目名称,点击properties/Flex Builder Path修改output folder URL,点击properties/Flex Build Path修改Flex SDK Version
10.运行flexDemo.mxml即可