Flex一个RemoteObject调用JAVA对象里面的多个方法


1、FLEX集合PureMVC进行项目开发(FLEX+BlazeDS+PureMVC)
2、FLEX的持久层调用java层代码的时候,如果要调用一个对象里面的多个方法,做法如下


package com.wynlink.model
{
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.events.ResultEvent;
import mx.rpc.remoting.Operation;
import mx.rpc.remoting.RemoteObject;

import org.puremvc.as3.patterns.proxy.Proxy;

public class MobilePhoneProxy extends Proxy
{
public static const NAME:String = "MobilePhoneProxy";
public static const GET_PHONE_USER_CALLBACK:String = "getPhoneUserCallBack";
public static const GET_PHONE_TEMPLATE_CALLBACK:String = "getPhoneTemplateCallBack";

private var mobile:RemoteObject;
public var op1:Operation;
public var op2:Operation;

public function MobilePhoneProxy(data:Object=null)
{
super(NAME, data);

mobile = new RemoteObject();
mobile.destination = "phone";
mobile.endpoint = "/Project_ydq/messagebroker/amf";
mobile.showBusyCursor = true;
//操作定义
op1 = new Operation();
op1.addEventListener(ResultEvent.RESULT, getPhoneUserCallBack);//如果是此事件,则回调此方法
op2 = new Operation();
op2.addEventListener(ResultEvent.RESULT, getPhoneTemplateCallBack);
//多个操作加入远程对象
mobile.operations = {"getPhoneUser" : op1,"getPhoneTemplate" : op2};//JAVA对象里的方法
//mobile.addEventListener(ResultEvent.RESULT, showSMSshowSMS);
}

private function getPhoneUserCallBack(event:ResultEvent):void {
var re:ArrayCollection = event.message.body as ArrayCollection;
if(re.length == 0){
this.sendNotification(GET_PHONE_USER_CALLBACK,re);
}
this.sendNotification(GET_PHONE_USER_CALLBACK,null);

}

private function getPhoneTemplateCallBack(event:ResultEvent):void {

}

/* 获取接收短信的所有用户 */
public function getUserInfo():void {
//mobile.getPhoneUser();
op1.send();
}

/* 获取短信模板 */
public function getPhoneTemplate():void {
op2.send();
}

public function ShowMobilePhonePanel():void{

}
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值