Hi,

you would need to be carefull, because the command instances are
created once only at creation of the FrontController. By creating a
delegate instance, you are using the ServiceLocator to look up the
remote object, however, if your service locator hasn't been
initialized yet, you may get  a no service found error. So make sure
your services are created before you front controller if you are going
to take this approach.



--- In flexcoders@yahoogroups.com, "flexcoding" <[EMAIL PROTECTED]> wrote:
> Is it OK to have a constructor in the Command classes and have 
> delegate initialized there rather than doing it in every time 
> execute method is called?
> 
> So Could the code of LoginCommand of sample code that came with 
> CAIRNGORM 0.99 be changed to:
> 
> class org.nevis.cairngorm.samples.login.commands.LoginCommand 
> implements Command, Responder
> {
>    private var delegate: CustomerDelegate;
> 
>    public function LoginCommand ()
>    {
>       delegate = new CustomerDelegate( this );
>    }
> 
>    public function execute( event:Event ) : Void
>    {
>       var loginVO : LoginVO = LoginVO( event.data );
>       delegate.login( loginVO );
>    }
> 
> //-------------------------------------------------------------------
> ------
> 
>    public function onResult( event : Object ) : Void
>    {      
>       ModelLocator.workflowState = 
> ModelLocator.VIEWING_LOGGED_IN_SCREEN;
>       
>       var loginDate : Date = Date( event.result );   
>       ModelLocator.loginDate = loginDate;
>    }
> 
> //-------------------------------------------------------------------
> ------
> 
>    public function onFault( event : Object ) : Void
>    {
>       ModelLocator.statusMessage = "Your username or password was 
> wrong, please try again.";
>    }
> }
> 
> from
> 
> /*
> 
> Copyright 2005 iteration::two Ltd
> 
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
> 
>     http://www.apache.org/licenses/LICENSE-2.0
> 
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
> implied.
> See the License for the specific language governing permissions and
> limitations under the License.
> 
> @ignore
> */
> import org.nevis.cairngorm.business.Responder;
> import org.nevis.cairngorm.commands.Command;
> import org.nevis.cairngorm.control.Event;
> import org.nevis.cairngorm.samples.login.business.CustomerDelegate;
> import org.nevis.cairngorm.samples.login.vo.LoginVO;
> import org.nevis.cairngorm.samples.login.model.ModelLocator;
> 
> /**
>  * @version   $Revision: 1.4 $
>  */
> class org.nevis.cairngorm.samples.login.commands.LoginCommand 
> implements Command, Responder
> {
> 
>    public function execute( event:Event ) : Void
>    {
>       var delegate: CustomerDelegate = new CustomerDelegate( 
> this );     
>       var loginVO : LoginVO = LoginVO( event.data );
>       delegate.login( loginVO );
>    }
> 
> //-------------------------------------------------------------------
> ------
> 
>    public function onResult( event : Object ) : Void
>    {      
>       ModelLocator.workflowState = 
> ModelLocator.VIEWING_LOGGED_IN_SCREEN;
>       
>       var loginDate : Date = Date( event.result );   
>       ModelLocator.loginDate = loginDate;
>    }
> 
> //-------------------------------------------------------------------
> ------
> 
>    public function onFault( event : Object ) : Void
>    {
>       ModelLocator.statusMessage = "Your username or password was 
> wrong, please try again.";
>    }
> }




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to