PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: yeremy on July 29, 2008, 12:21:19



Title: LibraryDelegate - Manage few Service Sources
Post by: yeremy on July 29, 2008, 12:21:19
hi All!

i've been working in the login component..and it is done,  now i need work with another remote object..i've used a LibraryDelegate to manage a service with differents sources...but i'm not sure about it is a good way to do that.

the following code is that i've used :

-----------------Login Proxy ------------------------------------
this is a method inside the LoginProxy Class.

public function login(tryLoggin: LoginVO):void
      {
         var delegate:LibraryDelegate = new LibraryDelegate( new Responder( onLoginResult, onLoginFault ) );
         delegate.setSourceService( LibraryDelegate.SERVICE_USER );
         delegate.login( tryLoggin );
         
      }

-----------------Library Delegate ------------------------------------
package com.me.myapp.model.business

             public class LibraryDelegate
   {
      private var responder: IResponder;
      private var service : RemoteObject;
      
      public var currentService : int;
      
      public static const SERVICE_USER : uint = 1;
      public static const SERVICE_PRODUCT : uint = 2;
      
      public function LibraryDelegate( pResponder : IResponder )
      {
         service = new RemoteObject();
         
         //service.endpoint = "";
         service.destination = "GenericDestination";
         service.showBusyCursor = true;
         service.makeObjectsBindable = true;
         
         responder = pResponder;
      }
      
      public function setSourceService(pSelectorSource : uint):void
      {
         currentService = pSelectorSource;
         switch ( currentService )
         {
            case SERVICE_PRODUCT :
               service.source = "WebOrbTestBusinessLogic.Entities.Product";
               break;
            case SERVICE_USER :
               service.source = "WebOrbTestBusinessLogic.Entities.User";
            default :      
         }
         
      }

}


i hope somebody can help me with this!

Thanks!


Title: Re: LibraryDelegate - Manage few Service Sources
Post by: puremvc on July 29, 2008, 07:43:33
No problem with using a delegate. I don't see your LibraryDelegate.login method here, but I assume it works for you and you're just looking for a thumbs up that its a good idea?

-=Cliff>