Hi,
Thanks for the reply. You must be a very experienced programmer
because you just looked at the suggestion and found the problem it
will create two steps down. I have experienced the same problem that
you mentioned below if I use recommended mx:Application tag
instead of cairngorm:CairngormApplication tag, but I had to spend
considerable time to nail down the cause, which I believe, and like
you said, is that the ServiceLocator.getInstance() is failing
because it hasn't been initialized yet.
1. How can I ensure that my services are created before my front
controller in the Index?
2. Does this approach of creating delegates in Command Constructor
has any advantage/disadvantage?
Thanks Regards,
Rohit Chhabra.
--- In flexcoders@yahoogroups.com, Daniel Harfleet
[EMAIL PROTECTED] wrote:
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 ~--
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM
~-
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: