Flex3与BlazeDS HelloWorld 详解
BlazeDS的下载和介绍: 按照图中进行配置 指定已经下载的blazeds.war 配置url 注意context的修改,不然运行程序会报404. package com; public class HelloWorld { public String say(String username) { System.out.println("hello"); return "你好!" + username; } public String login(String username,String password) { System.out.println("login"); if(username.equals("admin") && password.equals("admin")) { return "success"; } else { return "failure"; } } }
<?xml version="1.0" encoding="UTF-8"?> <service id="remoting-service" class="flex.messaging.services.RemotingService"> <adapters> <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/> </adapters> <default-channels> <channel ref="my-amf"/> </default-channels> <!-- 目标java类 --> <destination id="helloworld"> <properties> <source>com.HelloWorld</source> </properties> </destination> </service> 7.编写mxml文件: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; import mx.controls.Alert; //hello事件 private function helloClick():void { this.hello.say(this.username.text); } //登录事件 private function loginClick():void { this.login.login(this.username.text,this.password.text); } //处理hello事件 返回值 private function resultHandler(e:ResultEvent):void { Alert.show(e.result.toString()); } //处理登录事件返回值 private function resultLoginHandler(e:ResultEvent):void { Alert.show(e.result as String); } ]]> </mx:Script> <!--远程对象调用--> <mx:RemoteObject id="hello" destination="helloworld" result="resultHandler(event)" /> <mx:RemoteObject id="login" destination="helloworld" result="resultLoginHandler(event)" /> <mx:TextInput id="username" x="187" y="99" width="119"/> <mx:Label x="123" y="101" text="username:"/> <mx:Label x="123" y="141" text="password:"/> <mx:TextInput id="password" x="187" y="139" width="119" /> <mx:Button x="241" y="184" label="Login" click="loginClick()"/> <mx:Button x="123" y="184" label="HelloWorld" click="helloClick()"/> </mx:Application>
?效效果图
源码下载 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 自定义react-native-router-flux的默认导航栏
- c# – 我的NamedPipeServerStream为什么不等?
- 【Oracle】START WITH...CONNECT BY PRIOR...递归查询
- jaxb xml序列化与Java类的转化
- 怎么在Oracle官网下载到旧版本的jdk
- React-Native ListView onPress – undefined不是对象
- 如何显示循环控制变量在C for循环体内没有改变?
- Oracle 分区表
- ruby-on-rails – 将图像和文本放在link_to帮助器(Rails)中
- 对象转xml or xml转对象(XStream and jaxb)