Chinese - PureMVC IIBP Translation

Embed Size (px)

Citation preview

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    1/44

    PureMVC

    ActionScript 3 MXML

    : Tamt

    : 5/19/2008

    : Cliff Hall

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    2/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 2 of 44 5/20/2008 11:17 PM

    PureMVC 4 Model Proxy 4

    View Mediator 4

    Controller Command 4

    Faade Core 5

    Observer Notification 5

    NotificationCommand 5

    MediatorNotification 6

    ProxyNotification 6

    Faade 7

    Faade? 7

    Faade 7

    Faade 10

    Notification 12 EventNotification 12

    NotificationEvent 13

    Command 14

    SimpleCommandMacroCommand 15

    CommandMediator, Proxy 15

    16

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    3/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 3 of 44 5/20/2008 11:17 PM

    Mediator 21

    Mediator 21

    View Component 22

    View Component 23

    MediatorNotification 25

    MediatorProxyMediatorMediator 27

    View ComponentMediator 28

    Proxy 33 Proxy 34

    34

    Mediator 36

    37

    Remote Proxy 38

    PureMVC RIA

    PureMVC PureMVC

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    4/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 4 of 44 5/20/2008 11:17 PM

    PureMVCPureMVCModelView

    Controller

    PureMVCMVC

    ModelViewController

    PureMVCFaadeFaade

    Model Proxy

    Model Proxy Proxy

    Model

    View Mediator

    View Mediator Mediator

    View Component Flex DataGrid

    Notification

    Controller Command

    Controller Command Command

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    5/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 5 of 44 5/20/2008 11:17 PM

    PureMVCController Command

    Command Proxy Notification

    Command

    Faade Core

    Faade Model View

    Controller Public

    Faade Faade

    MVC ModelView

    Controller

    ProxyMediator Command Faade

    Observer Notification

    PureMVC Flash EventDispatcher/Event

    PureMVC Flash Event EventDispatcher

    PureMVC Observer/Notification

    Proxy,

    Mediator, Command Facade Notification

    Notification

    NotificationCommand

    Facade Command Notification Notification

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    6/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 6 of 44 5/20/2008 11:17 PM

    PureMVCNotificationCommand

    Command Controller Command

    View Model

    MediatorNotification

    View Mediator Mediator listNotifications

    Mediator Notification

    NotificationMediator handleNotification Notification

    ProxyNotification

    Proxy NotificationProxy

    Notification Proxy

    Notification

    Proxy Notification View

    Controller

    View Controller Proxy Notification

    Proxy

    View Controller Model

    Model

    View/Controller

    Model

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    7/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 7 of 44 5/20/2008 11:17 PM

    Faade

    MVC PureMVC Model View

    Controller PureMVC Faade

    Faade ModelView Controller

    Faade

    MVC

    Faade Faade

    Controller Command Notification

    Command Model View

    Faade?

    Faade ,

    Faade Faade

    ApplicationFacade

    CommandMediator Proxy

    Flex

    MXML Flash Stage

    PureMVC

    Facade Facade

    startup

    PureMVC

    Faade

    Faade

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    8/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 8 of 44 5/20/2008 11:17 PM

    Faade

    Faade

    ApplicationFacade.as:

    package com.me.myapp

    {

    import org.puremvc.as3.interfaces.*;

    import org.puremvc.as3..patterns.facade.*;

    import com.me.myapp.view.*;

    import com.me.myapp.model.*;

    import com.me.myapp.controller.*;

    // MyApp Faade

    publicclass ApplicationFacade extends Faade implements IFacade

    {

    // Notification

    public static const STARTUP:String = "startup";

    public static const LOGIN:String = "login";

    // ApplicationFacade

    public staticfunction getInstance() : ApplicationFacade

    {

    if( instance == null ) instance = new ApplicationFacade( );

    return instance as ApplicationFacade;

    }

    // Command Command Notification

    override protectedfunction initializeController( ) : void

    {

    super.initializeController();

    registerCommand( STARTUP, StartupCommand );

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    9/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 9 of 44 5/20/2008 11:17 PM

    Faade

    Faade

    registerCommand( LOGIN, LoginCommand );

    registerCommand( LoginProxy.LOGIN_SUCCESS,

    GetPrefsCommand );

    }

    // PureMVC

    public function startup( app:MyApp ) : void

    {

    sendNotification( STARTUP, app );

    }

    }

    }

    o ApplicationFacade PureMVC Faade Faade

    IFacade

    o ApplicationFacade

    o getInstance ApplicationFacade

    protect

    ApplicationFacade

    o NotificationFaade

    Notification

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    10/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 10 of 44 5/20/2008 11:17 PM

    Faade

    Faade

    o Controller Command Notification

    Notification Command

    o startup

    Notification StartupCommand

    Faade

    PureMVC Faade ModelView

    Controller

    Faade ModelView Controller

    Faade

    Faade Flex

    MyApp.mxml:

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    11/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 11 of 44 5/20/2008 11:17 PM

    Faade

    Faade

    ApplicationFaade startup

    AIR applicationCompletecreationComplete

    Flash startup 1

    o MXML

    Flex

    o ApplicationFacade

    o getInstance

    creationComplete Facade ModelView

    Controller Mediator

    Proxy

    o Application creationComplete

    startup

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    12/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 12 of 44 5/20/2008 11:17 PM

    Faade

    Faade

    Application

    Faade

    Application Flash Movie Faade

    PureMVC

    Notification

    PureMVC

    ActionScript flash.events PureMVC

    AS C#J2ME

    Flash

    Notification

    Notification Event

    PureMVC

    Event Notification

    Event IeventDispatcher Flash Event

    Event dispatcher dispatcher

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    13/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 13 of 44 5/20/2008 11:17 PM

    Notification

    Event Notification

    Facade Proxy NotificationMediators

    NotificationNotification Command Command

    Notification/

    Notification

    ActionScript [ Notification

    app STARTUP

    Notification]

    Flash Event Notification Notification

    Object "" Notification

    Notification

    Notification

    Proxy Mediator Mediator

    Proxy Notification

    Mediator

    Proxy Noification Mediator Notification

    Notification

    NotificationEvent

    Notification Faade

    Notification Facade collaborator

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    14/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 14 of 44 5/20/2008 11:17 PM

    Notification

    NotificationEvent

    Notification

    ApplicationConstants Notification

    Notification

    Notification

    Event Faade Event

    Event

    ApplicationView Component Data

    Object Mediator Proxy Event

    Notification View Component

    Data Object

    View Component Data Object Mediator

    Proxy Eventview componentmediator

    data objectproxy Mediator Proxy

    PureMVC Notification

    Mediator/View Proxy/Data

    Command

    ApplicationFacade Controller Notification Command

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    15/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 15 of 44 5/20/2008 11:17 PM

    Command

    Controller NotificationController

    Notification Command Notification

    execute

    Command Controller

    Notification execute

    long-living object Command

    SimpleCommandMacroCommand

    Command ICommand PureMVC

    ICommand SimpleCommandMacroCommand

    SimpleCommand execute execute

    Inotification

    MacroCommand Command

    Command Notification

    MacroCommand initializeMacroCommand

    addSubCommand Command

    SimpleCommand MacroCommand Command

    CommandMediator, Proxy

    Notification Controller Command

    Controller Command

    Command

    o MediatorProxy Command

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    16/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 16 of 44 5/20/2008 11:17 PM

    Command

    CommandMediator, Proxy

    o Notification Command Mediator

    o Proxy Mediator

    Command

    Command Proxy Notification

    CommandMediator

    Proxy

    Command

    Business Logic Domain Logic

    Command Business Logic Domain

    LogicBusiness LogicModel

    Model Proxy Proxy

    Domain Logic API

    Command .

    Mediator Proxy Command View

    Component Data Object Command

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    17/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 17 of 44 5/20/2008 11:17 PM

    Command

    View Component

    Data Object

    Command Mediator Proxy Mediator Proxy

    Command

    StartupCommand.as:

    package com.me.myapp.controller{

    import org.puremvc.as3.interfaces.*;

    import org.puremvc.as3.patterns.command.*;

    import com.me.myapp.controller.*;

    // MacroCommand.

    publicclass StartupCommand extends MacroCommand

    {

    //Command MacroCommand.

    overrideprotectedfunction initializeMacroCommand() : void

    {

    addSubCommand( ModelPrepCommand );

    addSubCommand( ViewPrepCommand );

    }

    }

    }

    Command MacroCommand

    FIFO

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    18/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 18 of 44 5/20/2008 11:17 PM

    Command

    PureMVC startup

    Model

    Model

    startupModel View

    ModelPrepCommand.as:

    package com.me.myapp.controller

    {

    import org.puremvc.as3.interfaces.*;

    import org.puremvc.as3.patterns.observer.*;

    import org.puremvc.as3.patterns.command.*;

    import com.me.myapp.*;

    import com.me.myapp.model.*;

    // Proxy

    publicclass ModelPrepCommand extends SimpleCommand

    {

    // MacroCommand

    override publicfunction execute( note : INotification ) : void

    {

    facade.registerProxy( new SearchProxy() );

    facade.registerProxy( new PrefsProxy() );

    facade.registerProxy( new UsersProxy() );

    }

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    19/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 19 of 44 5/20/2008 11:17 PM

    Command

    }

    }

    Model

    Proxy

    ModelPrepCommand SimpleCommand

    Model MacroCommand

    Faade startup

    Proxy Command

    ModelProxy

    ViewPrepCommand.as:

    package com.me.myapp.controller

    {import org.puremvc.as3.interfaces.*;

    import org.puremvc.as3.patterns.observer.*;

    import org.puremvc.as3.patterns.command.*;

    import com.me.myapp.*;

    import com.me.myapp.view.*;

    // Mediator View.

    publicclass ViewPrepCommand extends SimpleCommand

    {

    override publicfunction execute( note : INotification ) : void

    {

    var app:MyApp = note.getBody() as MyApp;

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    20/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 20 of 44 5/20/2008 11:17 PM

    Command

    facade.registerMediator( new ApplicationMediator( app ) );

    }

    }

    }

    SimpleCommand View

    MacroCommand

    Mediator ApplicationMediator

    ApplicationMediator Appliction View

    Mediator Mediator

    Notification Application

    STARTUP Notification Application

    MyApp

    Application View Component

    View Component

    Mediator Mediator

    Mediaotr (View component)

    Mediator View Component Application

    Application Mediator

    Application Application Mediator

    Mediator

    Command Model View Command

    Model View

    Model View Model View

    Command

    Command Model View

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    21/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 21 of 44 5/20/2008 11:17 PM

    Command

    Model (domain logic) Command

    Proxy

    Mediator

    Mediator View Component Flex DataGrid Flash

    MovieClip

    Flash Mediator View Component

    Component Mediator Notification

    Mediator

    FlashFlex AIR UI

    ActionScript PureMVC

    Silverlight J2ME PureMVC

    RIA

    PureMVC UI

    PureMVC

    PureMVC View Component UI

    ComponentFlexJava C#

    View Component

    API

    Mediator View Component View

    Component API

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    22/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 22 of 44 5/20/2008 11:17 PM

    Mediator

    Mediator

    Mediator View Component

    Notification

    Mediator Proxy Mediator

    Proxy Mediator Proxy

    View Component

    PureMVC Mediator name

    Object

    Mediator View Component

    protect viewComponent

    Object

    Mediator setViewComponent

    View Component

    Object API Object

    ActionScript setter getter setter getter

    setter getter

    Mediator getter View Component

    getter

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    23/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 23 of 44 5/20/2008 11:17 PM

    Mediator

    View Component

    protectedfunctionget controlBar() : MyAppControlBar

    {

    return viewComponent as MyAppControlBar;

    }

    Mediator

    MyAppControlBar ( viewComponent ).searchSelction =

    MyAppControlBar.NONE_SELECTED;

    controlBar.searchSelction =

    MyAppControlBar.NONE_SELECTED;

    View Component

    Mediator View Component UI ApplicationToolBar button control

    Control from View Component

    View Component Mediator

    View Component

    Mediator Controller Model

    Notification View Component

    Flash setViewComponent View Component

    controlBar.addEventListener( AppControlBar.BEGIN_SEARCH,

    onBeginSearch );

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    24/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 24 of 44 5/20/2008 11:17 PM

    Mediator

    View Component

    Mediator

    Mediator

    o

    o View Component

    o Proxy

    o Notification Mediatora

    Command

    o Mediator

    Notification Mediator

    o Mediator Mediator

    Command

    o Mediator Mediator

    Mediator

    o Proxy Notification

    Mediator

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    25/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 25 of 44 5/20/2008 11:17 PM

    Mediator

    Mediator Notification

    Mediator PureMVC

    Mediator PureMVC Mediator

    listNotificationInterests NotificationMediator

    listNotificationInterests Notification

    Notification

    Notification Faade

    override publicfunction listNotificationInterests() : Array

    {

    return [

    ApplicationFacade.SEARCH_FAILED,

    ApplicationFacade.SEARCH_SUCCESS

    ];

    }

    Notification Mediator

    Mediator handleNotification

    Notification

    handleNotification switch/caseif/else if

    Notification

    Notification Mediator

    Notification Proxy

    Notification Command

    Mediator

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    26/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 26 of 44 5/20/2008 11:17 PM

    Mediator

    Mediator Notification

    override publicfunction handleNotification( note : INotification ) : void{

    switch ( note.getName() )

    {

    case ApplicationFacade.SEARCH_FAILED:

    controlBar.status = AppControlBar.STATUS_FAILED;

    controlBar.searchText.setFocus();

    break;

    case ApplicationFacade.SEARCH_SUCCESS:

    controlBar.status = AppControlBar.STATUS_SUCCESS;

    break;

    }

    }

    }

    MediatorhandleNotification

    Notification 45

    Mediator Notification

    Mediator Mediator

    [Mediator View Component Event

    Proxy NotificationMediator ] Mediator Notification Event

    Notification

    handleNotification

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    27/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 27 of 44 5/20/2008 11:17 PM

    Mediator

    Mediator Notification

    Notification View Component

    View Component

    NotificationMediator

    switch/case Notification

    Notification handleNotification switch/ case Notification switch/case

    Notification

    switch/case PureMVC

    Mediator PureMVC

    Mediator View Component

    UN conference

    Mediator PureMVC

    Mediator Proxy Mediator Mediator

    View Model

    View Model Model ViewView Model

    Model View

    Mediator Proxy Proxy API Data Object

    Command View Model

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    28/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 28 of 44 5/20/2008 11:17 PM

    Mediator

    Mediator Proxy Mediator Mediator

    Mediator View Mediator API

    View

    Mediator Mediator Notification

    Mediator

    Mediator View Component

    Notification

    Mediator View Component Event

    Notification View Component

    Mediator Proxy

    Command MediatorBusiness Logic

    Command Command View View

    Model

    View Component Mediator

    LoginPanel LoginPanelMediator

    LoginPanel

    LoginPanel LoginPanelMediator LoginPanel

    TRY_LOGIN LoginPanelMediator

    LoginVO Notification

    LoginPanel.mxml:

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    29/44

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    30/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 30 of 44 5/20/2008 11:17 PM

    Mediator

    View Component Mediator

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    31/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 31 of 44 5/20/2008 11:17 PM

    Mediator

    View Component Mediator

    LoginPanelMediator LOGIN_FAILED LOGIN_SUCCESS

    LoginPanel

    LoginPanelMediator.as:

    package com.me.myapp.view

    {

    import flash.events.Event;

    import org.puremvc.as3.interfaces.*;

    import org.puremvc.as3.patterns.mediator.Mediator;

    import com.me.myapp.model.LoginProxy;

    import com.me.myapp.model.vo.LoginVO;

    import com.me.myapp.ApplicationFacade;

    import com.me.myapp.view.components.LoginPanel;

    // LoginPanelMediator

    public class LoginPanelMediator extends Mediator implements IMediator

    {

    public static const NAME:String = 'LoginPanelMediator';

    public function LoginPanelMediator( viewComponent:LoginPanel )

    {

    super( NAME, viewComponent );

    LoginPanel.addEventListener( LoginPanel.TRY_LOGIN,

    onTryLogin );

    }

    //MediatorNotification

    override publicfunction listNotificationInterests( ) : Array

    {

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    32/44

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    33/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 33 of 44 5/20/2008 11:17 PM

    Mediator

    View Component Mediator

    }

    }

    }

    LoginPanelMediator LoginPanel

    onTryLogin Login

    onTryLogin LOGIN Notification

    LoginVO

    ApplicationFacade LoginCommand

    Notification LoginCommand LoginProxy

    LoginVOLoginProxy

    LOGIN_SUCCESS LOGIN_FAILED

    NotificationProxy

    LoginPanelMediator LOGIN_SUCCESS LOGIN_FAILED

    Notification Notification Mediaotr

    LoginPanel loginStatus LOGGED_IN

    NOT_LOGGED_INLoginVO

    Proxy

    Proxy Pattern

    PureMVC Proxy

    Proxy Proxy

    Proxy DataObject API Data Object

    Data Object Notifidation

    Remote Proxy Proxy Remote service

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    34/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 34 of 44 5/20/2008 11:17 PM

    Proxy

    Proxy Proxy

    Notification

    Proxy

    Proxy Data Object Data Object

    PureMVC Proxy Model

    Proxy Proxy

    Proxy Pattern

    o Remote Proxy, Proxy

    o Proxy and Delegate, Proxy

    Delegate

    o Protection Proxy,

    o Virtual Proxy,

    o Smart Proxy,

    Proxy (name) Object Object

    Proxy

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    35/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 35 of 44 5/20/2008 11:17 PM

    Proxy

    setData

    Mediator View Component

    Data Object

    Data Object

    Data Object

    ActionScript getter setter

    Proxy getter Data Object getter Data Object

    publicfunctionget searchResultAC () : ArrayCollection{

    return data as ArrayCollection;

    }

    publicfunctionget resultEntry( index:int ) : SearchResultVO{

    return searchResultAC.getItemAt( index ) as

    SearchResultVO;

    }

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    36/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 36 of 44 5/20/2008 11:17 PM

    Proxy

    Mediator

    var item:SearchResultVO =

    ArrayCollection ( searchProxy.getData() ).lastResult.getItemAt( 1 ) as

    SearchResultVO;

    var item:SearchResultVO = searchProxy.resultEntry( 1 );

    Mediator

    Proxy Notification Proxy View

    Proxy

    Proxy Mediator Data

    Object

    Notification Notification Command

    Mediator Proxy Notification

    Model View Controller

    Model

    Model View Controller Model

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    37/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 37 of 44 5/20/2008 11:17 PM

    Proxy

    Model View/Controller

    Domain Logic Proxy

    Model View Controller

    Proxy

    Domain Logic Proxy

    Mediator Command

    Proxy

    logic

    Mdeiator retrieve Proxy

    Mediator

    Domain Logic View

    Domain ModelView Domain

    Model View

    RIA

    use case PDA

    Model

    Model

    View Controller

    Mediator

    Model

    View

    Model

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    38/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 38 of 44 5/20/2008 11:17 PM

    Proxy

    Remote Proxy

    Remote Proxy Remote location Data

    Object Proxy

    Proxy remote service

    Flash/Flex

    HTTPServiceWebServiceRemoteObjectDataService

    XMLSocket Proxy

    Remote Proxy

    get/set

    Proxy

    Remote Proxy

    Proxy Notification

    Notification

    o View Component

    o Mediator RemoteProxy

    searchCriteria

    o Proxy searchCriteria setter

    HTTPService result fault

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    39/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 39 of 44 5/20/2008 11:17 PM

    Proxy

    Remote Proxy

    o HTTPService ResultEvent

    Proxy

    o Proxy Notification

    Notification

    o Notification Mediator

    Notification View

    Component dataProvider

    LoginProxy LoginVO Value Object

    LoginVO

    package com.me.myapp.model.vo

    {

    //AS3 VORemote Class

    [RemoteClass(alias="com.me.myapp.model.vo.LoginVO")]

    [Bindable]

    publicclass LoginVO

    {

    publicvar username: String;

    publicvar password: String;

    publicvar authToken: String;//

    }

    }

    LoginProxy logging inlogging

    out

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    40/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 40 of 44 5/20/2008 11:17 PM

    Proxy

    Remote Proxy

    LoginProxy:

    package com.me.myapp.model

    {

    import mx.rpc.events.FaultEvent;

    import mx.rpc.events.ResultEvent;

    import mx.rpc.remoting.RemoteObject;

    import org.puremvc.as3.interfaces.*;

    import org.puremvc.as3.patterns.proxy.Proxy;import com.me.myapp.model.vo.LoginVO;

    // Proxy

    publicclass LoginProxy extends Proxy implements IProxy {

    public static const NAME:String = 'LoginProxy';

    public static const LOGIN_SUCCESS:String = 'loginSuccess';

    public static const LOGIN_FAILED:String = 'loginFailed';

    public static const LOGGED_OUT:String = 'loggedOut';

    privatevar loginService: RemoteObject;

    publicfunction LoginProxy () {

    super( NAME, new LoginVO ( ) );

    loginService = new RemoteObject();

    loginService.source = "LoginService";

    loginService.destination = "GenericDestination";

    loginService.addEventListener( FaultEvent.FAULT,

    onFault );

    loginService.login.addEventListener( ResultEvent.RESUL

    T, onResult );

    }

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    41/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 41 of 44 5/20/2008 11:17 PM

    Proxy

    Remote Proxy

    // getterdata

    publicfunctionget loginVO( ) : LoginVO {

    return data as LoginVO;

    }

    //logivVOauthToken

    publicfunctionget loggedIn():Boolean {

    return ( authToken != null );

    }

    // authToken

    publicfunctionget authToken():String {

    return loginVO.authToken;

    }

    //

    public login( tryLogin:LoginVO ) : void {

    if( ! loggedIn ) {

    loginVO.username= tryLogin.username;

    loginVO.password = tryLogin.password;

    } else {

    logout();

    login( tryLogin );

    }

    }

    // LoginVO

    publicfunction logout( ) : void

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    42/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 42 of 44 5/20/2008 11:17 PM

    Proxy

    Remote Proxy

    {

    if( loggedIn ) loginVO = new LoginVO( );

    sendNotification( LOGGED_OUT );

    }

    //

    privatefunction onResult( event:ResultEvent ) : void

    {

    setData( event.result ); // immediately available as

    loginVO

    sendNotification( LOGIN_SUCCESS, authToken );

    }

    //

    privatefunction onFault( event:FaultEvent) : void

    {

    sendNotification( LOGIN_FAILED,

    event.fault.faultString );

    }

    }

    }

    LoginCommand LoginProxy

    GetPrefsCommand LOGIN_SUCCESS

    Notification Notificaiton authToken

    preferences

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    43/44

    PureMVC Futurescale Futurescale, Inc. Copyright 2006-08, Some rights

    reserved PureMVC Creative Commons 3.0 Attribution PureMVC

    Futurescale

    Page 43 of 44 5/20/2008 11:17 PM

    Proxy

    Remote Proxy

    LoginCommand:

    package com.me.myapp.controller {

    import org.puremvc.as3.interfaces.*;

    import org.puremvc.as3.patterns.command.*;

    import com.me.myapp.model.LoginProxy;

    import com.me.myapp.model.vo.LoginVO;

    publicclass LoginCommand extends SimpleCommand {override publicfunction execute( note: INotification ) : void {

    var loginVO : LoginVO = note.getBody() as LoginVO;

    var loginProxy: LoginProxy;

    loginProxy = facade.retrieveProxy( LoginProxy.NAME ) as

    LoginProxy;

    loginProxy.login( loginVO );

    }

    }

    }

    GetPrefsCommand:

    package com.me.myapp.controller {

    import org.puremvc.as3.interfaces.*;

    import org.puremvc.as3.patterns.command.*;

    import com.me.myapp.model.LoginProxy;

    import com.me.myapp.model.vo.LoginVO;

    publicclass GetPrefsCommand extends SimpleCommand {

    override publicfunction execute( note: INotification ) : void {

    var authToken : String = note.getBody() as String;

    var prefsProxy : PrefsProxy;

  • 8/8/2019 Chinese - PureMVC IIBP Translation

    44/44