您的位置:首页 > 大数据 > 人工智能

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

2010-05-14 02:23 369 查看
在上一节,我们利用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文件夹。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:view="org.rianotes.CairngormSample.view.*"
layout="absolute" xmlns:control="org.rianotes.CairngormSample.control.*" xmlns:business="org.rianotes.CairngormSample.business.*">

<mx:Script>
<![CDATA[
import org.rianotes.CairngormSample.model.ViewModelLocator;
[Bindable]
private var model:ViewModelLocator = ViewModelLocator.getInstance();
]]>
</mx:Script>

<!--Cairngorm FrontController :讓app中擁有SampleController-->
<control:SampleController id="controller" />

<!--Cairngorm Services-->
<business:Services id="services" />

<mx:ViewStack id="vsMain" width="100%" height="100%"
selectedIndex="{model.workflowState}">

<!--第0個View-->
<view:LoginView />

<!--第1個View-->
<view:MainView />
</mx:ViewStack>
</mx:Application>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐