您的位置:首页 > 其它

Flex+BlazeDS整合J2ee示例

2010-09-06 11:13 405 查看
一、首先配置好eclipse下Flex开发环境

http://blog.csdn.net/hujingn/archive/2010/08/31/5853691.aspx

二、下载部署BlazeDS

http://download.csdn.net/source/2665805

将下载的blazeds.war包,放入%TOMCAT_HOME%/webapps目录下。

三、创建Flex项目







使用MyEclipse加入web project





创建好后项目目录结构



然后使用eclipse把项目部署到tomcat下



四、应用

1、切换到Java透视图下,在src目录下创建Hello.java

<destination id="hello">
<properties>
<source>com.flex.Hello</source>
</properties>
</destination>


3、切换回Flex Development透视图,编辑flex_src/flexsample.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="#ffffff">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
function gg(evnet:ResultEvent):void{
var ff:String = evnet.result as String;
ggg.text = ff;
}
function remotingSayHello():void{
var sname:String = nameInput.text;
h.hello(sname);
}
]]>
</mx:Script>
<mx:RemoteObject destination="hello" id="h" result="gg(event)" endpoint="http://localhost:8080/flexsample/messagebroker/amf" >
</mx:RemoteObject>
<mx:TextArea id="ggg" x="109" y="122"/>
<mx:Button label="say hello" click="remotingSayHello();" x="144" y="193"/>
<mx:TextInput id="nameInput" x="109" y="73"/>
<mx:Label text="name" x="47" y="75"/>
</mx:Application>

重启tomcat

在flexsample.mxml文件上右键run as->Flex Application



在eclipse控制台也会打印出:

flex调用我了,真好!!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: