在上一节,我们利用FrontController 去映射 Event与Command

在这一节我们主要针对Command这部分动作做介紹。在RIA应用程序中,不可或缺的部份就是跟后台服务器连接进行数据传递。Command通过Delegate去做Services的部份(包含Remoting,WebServices,…等)

  • Command: 操作Cairngorm Business以及呼叫Cairngorm Delegates,这些回传所取得的资料Command会再将它更新到Model Locator
  • Delegate: 由Command所产生,将远程呼叫(RPC:remote procedure calls[HTTP, Web Services, etc])实例化,并将结果传回给Command。
  • Service:用来定义连接Server端的呼叫(RPC:remote procedure calls[HTTP, Web Services, etc]),来获取远程数据。 
    在Delegate中我们会作一个call service的部份,而Services相关的定义与设定,就纪录在Service Locator。

    延续上一个项目,我们修改LoginCommand的部份要通过Delegate去做Remoting,呼叫Server端 login function,去数据库查看判断账号密码是否正确。

    所以我们先在项目中新增business文件夹。

    (转)Cairngorm初学者入门教程 第六节--Cairngorm中Command利用Delegate与Service连接

    新增两个文件,一个是Service.mxml组件。用来定义纪录可以使用的Services。

    因为组件的类型不是內建,所以先随便选一个再改mxml的內容
    这里示范的是使用搭配.NET Remoting的Freeware ” FluorineFx “,可以参考這裡

    代码如下:

    <?xml version="1.0" encoding="utf-8"?>
    <cairngorm:ServiceLocator
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:cairngorm
    ="com.adobe.cairngorm.business.*">

    <!-- Login Service -->
    <mx:RemoteObject
    id="Remoting_Services"
    source
    ="Remoting.Services"
    destination
    ="fluorine"
    showBusyCursor
    ="true">
    <mx:method name="login" />
    </mx:RemoteObject>

    </cairngorm:ServiceLocator>
  • 相关文章:

    • 2021-09-03
    • 2021-10-25
    • 2021-12-27
    • 2022-01-20
    • 2022-03-09
    • 2022-12-23
    猜你喜欢
    • 2021-06-02
    • 2022-02-11
    • 2021-07-30
    • 2021-10-16
    • 2021-11-24
    • 2021-12-22
    相关资源
    相似解决方案