pureMVC 流程

puremve:
1.在页面 close="destroy()"
  creationComplete="init()"
2.在init()方法中facade.startup(RoleConfigNotification.ROLE_CONFIG_STARTUP,this);
3.在Facade中,
registerCommand(RoleConfigNotification.ROLE_CONFIG_STARTUP, RoleConfigCommand);

4.在Command 中,facade.registerProxy(new RoleConfigProxy(RoleConfigProxy.NAME,notification.getBody()));
根据一个notification.getName()来发送一个消息:facade.sendNotification(RoleConfigNotification.ROLE_CONFIG_INIT, notification.getBody());

5.在Mediator中,override public function  listNotificationInterests():Array{}

override public function handleNotification(notification:INotification):void
  {
   switch (notification.getName())
   {
    case RoleConfigNotification.ROLE_CONFIG_INIT:
     //处理业务,调用proxy
  }
}

6.Proxy执行成功:执行result(),发送一个消息:facade.sendNotification(RoleConfigNotification.ROLE_CONFIG_SETDATA,data.result);
   Mediator 接受消息
 执行失败:调用fault()方法
 它实现IProxy,mx.rpc.IResponder这两个接口,继承Proxy类
 它需要private var str:int;public static const NAME:String="RoleConfigProxy";

 proxy调用business

public  function result(data:Object):void
  {
   switch (str)

}

(1)业务:public class RoleConfigBusiness
 {
  private var responder:IResponder;
  private var service:RemoteObject;
  
  public function RoleConfigBusiness(responder:IResponder)
  {
   this.responder = responder;
   this.service = ServicesUtil.getService("roleConfigService");
  }
  
  public function initRoleConfig(pageSize:int): void
  {
   var call:Object = service.initRoleConfig(pageSize);
   call.addResponder(responder); //这两行固定写法,只需要改变一下service的方法名
  }
}

(2)Facade:
public class RoleConfigFacade extends Facade
 {
  public static const NAME:String ="NAME_Role_Config_Facade";
  public function RoleConfigFacade(key:String)
  {
   super(key);
  }
  
  public static function getInstance( key:String ) : RoleConfigFacade
  {
   if ( instanceMap[ key ] == null ) instanceMap[ key ]  = new RoleConfigFacade( key );
   return instanceMap[ key ] as RoleConfigFacade;
  }
  
  override protected function initializeController( ) : void  //需要实现的方法
  {
   super.initializeController();
   registerCommand(RoleConfigNotification.ROLE_CONFIG_STARTUP, RoleConfigCommand);
}}
(3)使用Button(事件监听,调用proxy,查询数据):
view.searchBtn.addEventListener(MouseEvent.CLICK, handleSearch);
private function handleSearch(event:MouseEvent):void{

 var proxy:RoleConfigProxy = facade.retrieveProxy(RoleConfigProxy.NAME) as RoleConfigProxy;
 proxy.search(role_name,itype,status,1,defaultPageSize);//调用proxy
}

 

(4)actionScript对空值的处理:

a.isNaN 函数:

 

(5)数据绑定:需要在mxml文件中定义一个变量:var role:Object;

需要一个与java中的vo对应的actionScript类:

下拉列表comBox: 绑定值需要使用selectedIndex

页面赋值:{role}

在业务层:需要转换成与java的vo对应的actionScript类

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值