Thanks for your answer Bjorn. I don’t really worry about the delegate for now.

Maybe I was not clear enough.

 

My question is: should a command get all it’s parameters through the event object or is it ok to refer to the model to get them?

Of course you can pass value objects to the command via the event object (as Bjorn suggested) but that’s basically the same as passing single variables - probably a bit neater though.

 

Can’t the command just refer to the model as shown below?

 

 

 

 public class LoginCommand implements Command, Responder
 {

            private var model:Model = Model.getInstance();


  public function execute(event:CairngormEvent):void
  {

           
   var delegate:LoginDelegate = new LoginDelegate(this);
   var loginEvt:LoginEvent = LoginEvent( event );
  

            //

            // this line has changed!

///delegate.login(loginEvt.userVO);

delegate.login(model.userVO);


  }
  
  public function onResult(event:*=null):void
  {
   var submitVO:UserVO = UserVO(event.token.user);
  }

 

 

 

 

 


From: [email protected] [mailto:[email protected]] On Behalf Of hank williams
Sent: Wednesday, 11 October 2006 12:36 PM
To: [email protected]
Subject: Re: [flexcoders] Cairngorm commands - best practise

 

Hmm... I'm not sure, but I dont think you understood the question. Your answer, as far as I can tell, does not seem responsive. But I'm not sure that I could repeat it and make it any clearer than robin's initial question. Perhaps you could re-read it.

Regards,
Hank

On 10/10/06, Bjorn Schultheiss <bjorn.schultheiss@qdc.net.au> wrote:

Not really necessary

 

On your delegate you can attached the userID to the call object and then access through your command.onResult param.token object

 

 public class LoginCommand implements Command, Responder
 {
  public function execute(event:CairngormEvent):void
  {
   var delegate:LoginDelegate = new LoginDelegate(this);
   var loginEvt:LoginEvent = LoginEvent( event );
   delegate.login(loginEvt.userVO);
  }
  
  public function onResult(event:*=null):void
  {
   var submitVO:UserVO = UserVO(event.token.user);
  }

 

 

 

 public class LoginDelegate
 {
  public function LoginDelegate(responder:Responder)
  {
   service = ServiceLocator.getInstance().getService('userGateway');
   this.responder = responder;
  }
  
  public function login(user:UserVO):void
  {
   var call:AsyncToken = service.validate(user);
   call.user = user;
   call.resultHandler = responder.onResult;
   call.faultHandler = responder.onFault;
  }
  
  private var service:AbstractService;
  private var responder:Responder
 }

 

 

 

Regards,

 

Bjorn Schultheiss

Senior Flash Developer

QDC Technologies

 

 


From: [EMAIL PROTECTED]ups.com [mailto:[EMAIL PROTECTED]ups.com] On Behalf Of Robin Burrer
Sent: Wednesday, 11 October 2006 11:12 AM
To: [EMAIL PROTECTED]ups.com
Subject: [flexcoders] Cairngorm commands - best practise

Hi there

Let's say I want to do a server request. I want to search my database for a particular keyword and return a record set.

The user would type in the keyword in a text area and I would then create a SearchDatabaseEvent which then would trigger a SearchDatabaseEventCommand and so on …

However I also want to send the userID when I do my server request. Should the SearchDatabaseCommand get the userID from the model or from the SearchDatabaseEvent (so I would have two properties in my event "keywords" and "userId")? The SearchDatabaseCommand obviously knows about the model because it has to populate the model with the result record set. So I could just get the user ID from the model when the "execute method" is triggered.

This approach seems a bit wired though because it seems that couples my command to strongly to the model. On the other hand it seems strange to query the model from my view to populate the SearchDatabaseEvent with userId property as well.

Any thoughts?

Cheers

Robin

 

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to