当前位置: 首页 > news >正文

唐山市网站建设_网站建设公司_CMS_seo优化

顺德新网站制作,如何搭建个人网站,电商网站建设收费,wordpress 上传腾讯云本节将讲述pureMVC示例中的Controller层。 Controller层有以下文件组成#xff1a; AddUserCommand.asDeleteUserCommand.asModelPrepCommand.asViewPrepCommand.asStartupCommand.asAddUserCommand 。顾名思义#xff0c;它是添加用户命令。让我们首先看看代码。 Addusercom… 本节将讲述pureMVC示例中的Controller层。 Controller层有以下文件组成 AddUserCommand.asDeleteUserCommand.asModelPrepCommand.asViewPrepCommand.asStartupCommand.asAddUserCommand 。顾名思义它是添加用户命令。让我们首先看看代码。 Addusercommand.as代码   package com.superwulei.controller  {      import com.superwulei.model.UserProxy;      import com.superwulei.model.vo.UserVO;            import mx.controls.Alert;            import org.puremvc.as3.interfaces.INotification;      import org.puremvc.as3.patterns.command.SimpleCommand;        public class AddUserCommand extends SimpleCommand      {          override public function execute(notification:INotification):void          {                            var user:UserVO  notification.getBody() as UserVO;              var userProxy:UserProxy  facade.retrieveProxy(UserProxy.NAME) as UserProxy;                            if(user.isValid){                  userProxy.addItem(user);              }else{                  Alert.show(请检查用户名和密码);              }          }                }  }    AddUserCommand是一个单一命令SimpleCommand自定义SimpleCommand必须继承SimpleCommand并重写execute方法。execute方法表示这个命令的执行。曾经在上一篇《pureMVC简单示例及其原理讲解——View层 》中提到的添加用户的逻辑代码应该在这里编写。还记得上一篇中提到的“View层本身不处理各种操作但是发送通知”么 上一篇中发送通知的代码 sendNotification(ApplicationFacade.USER_ADD,userForm.user);  拿出这段代码是特意的想说明AddUserCommand的execute方法中的notification.getBody()其实就是userForm.user严谨的说应该是userFrom.user作为参数传到execute方法中来。如此我们在这里通过userProxy.addItem(user)就实现了用户的添加。userProxy中的users就多了一个user。   DeleteUserCommand 删除用户命令。代码如下与添加用户道理一样不多言。 Deleteusercommand deleteusercommand.as代码   package com.superwulei.controller  {      import com.superwulei.model.UserProxy;      import com.superwulei.model.vo.UserVO;            import org.puremvc.as3.interfaces.INotification;      import org.puremvc.as3.patterns.command.SimpleCommand;        public class DeleteUserCommand extends SimpleCommand      {          override public function execute(notification:INotification):void          {              var user:UserVO  notification.getBody() as UserVO;              var userProxy:UserProxy  facade.retrieveProxy(UserProxy.NAME) as UserProxy;              userProxy.deleteItem(user);          }                }  }    ModelPrepCommand、ViewPrepCommand分别是Model层注册和View层注册。说道注册就要道一道。在pureMVC中一切总控制是facade因此无论是Proxy、Mediator还是Command都要在facade中注册。上面四个Command全部为SimpleCommand最后一个StartupCommand为MacroCommand复合命令。StartupCommand包含了多个SimpleCommand通过addSubCommand方法添加了子命令并在之后在facade上注册了AddUserCommand和DeleteUserCommand。 Modelprepcommand.as代码   package com.superwulei.controller  {      import com.superwulei.model.UserProxy;            import org.puremvc.as3.interfaces.INotification;      import org.puremvc.as3.patterns.command.SimpleCommand;        public class ModelPrepCommand extends SimpleCommand      {          override public function execute(notification:INotification):void          {              /* 注册Model */              facade.registerProxy(new UserProxy());          }      }  }     Viewprepcommand.as代码   package com.superwulei.controller  {      import com.superwulei.view.UserFormMediator;      import com.superwulei.view.UserListMediator;            import org.puremvc.as3.interfaces.INotification;      import org.puremvc.as3.patterns.command.SimpleCommand;        public class ViewPrepCommand extends SimpleCommand      {          override public function execute(notification:INotification):void          {              var app:MyPureMVCdemo  notification.getBody() as MyPureMVCdemo;              /* 注册View */              facade.registerMediator(new UserFormMediator(app.userForm));              facade.registerMediator(new UserListMediator(app.userList));          }      }  }     Startupcommand.as代码   package com.superwulei.controller  {      import com.superwulei.ApplicationFacade;            import org.puremvc.as3.patterns.command.MacroCommand;        public class StartupCommand extends MacroCommand      {          override protected function initializeMacroCommand():void{              addSubCommand(ModelPrepCommand);              addSubCommand(ViewPrepCommand);              /* 注册添加、删除用户命令 */              facade.registerCommand(ApplicationFacade.USER_ADD,AddUserCommand);              facade.registerCommand(ApplicationFacade.USER_DELETE,DeleteUserCommand);          }      }  }    通过使用facade的registerCommand就好象添加一个监听器一样当有sendNotification发送出来的时候就会有对应的Command的execute方法被执行。 Controller层包含的应该是整个应用程序的逻辑业务。 转载于:https://www.cnblogs.com/fuland/p/3632847.html
http://www.ihoyoo.com/news/11549.html

相关文章:

  • o2o网站设计公司重庆网站开发商城
  • 怎样 管理网站自己做的网站 360不兼容
  • 深圳网站建设比较有名的企业从零开始学网站建设知乎
  • 来个可以做渗透的网站中铁建设集团有限公司天津分公司
  • 遂宁建设局网站首页英文seo 文章发布类网站
  • 软件开发工程师级别大同优化推广
  • 汉中专业网站建设推广网站开发的选题依据
  • 商务网站创建网站备案 信息查询
  • 自建网站做电商十大免费行情软件
  • 织梦网站关键词安徽省建设厅建筑信息网
  • 企业网站搭建方案海安做网站的公司
  • 做网站用什么域名好大气广告设计网站源码 企业公司模板 dedecms5.7 企业网站
  • 凡科建设网站安全吗湖南长沙做网站
  • 淘宝可以在哪些网站上面打做推广做网站怎么写代码
  • 资源网站如何做淘宝网pc首页
  • 东莞制作企业网站公司专门做护肤品网站
  • 网站域名如何实名认证网络营销与管理专业
  • 网站建设 麦肯趋势搜索引擎优化论文
  • 做网站的中标公司开封建设教育协会网站
  • 网站手机客户端如何开发采购信息网
  • 金湖县城乡建设局网站国际购物平台都有哪些
  • 丽江网站建设c3sales网站是通过超链接
  • 企业管理系统的构成状况h5网站不利于优化吗
  • 重庆沙坪坝网站建设潍坊网站推广
  • 网站建设与管理维护说课百度指数的作用
  • 网站快速排名网站建设ag
  • 网站建设的常用技术湖南彩票网站开发
  • 常州网站关键词php mysql网站开发项目式教程
  • 品牌网站开发策划书公司宣传册设计制作
  • 兄弟连php网站开发哪里建设网站