Thanks a lot michael.
A step by step example would be extremely helpful. I'm sure it will
help me clarify a few things.
Please email the code to this email address: [EMAIL PROTECTED]
I re-think about the whole issue again and guess the thing that I
would like to figure out here is what exactly happens in flex when
you do this:
<cairngorm:ServiceLocator xmlns:mx="http://www.macromedia.com/2003/
mxml" xmlns:cairngorm="org.nevis.cairngorm.business.*" >
<mx:RemoteObject id="customerDelegate" source="org.nevis.
cairngorm.samples.login.LoginDelegate"
result="event.call.resultHandler( event )"
fault="event.call.faultHandler( event )">
</mx:RemoteObject>
</cairngorm:ServiceLocator>
This is the way that you subclass a class in flex. but does flex
really create a class that inherits from ServiceLocator class or does
it create something else which "somehow" copies the code from
ServiceLocator class and create a new class with a property of
RemoteObject ?
if it is really subclassing, then in your code, when you do
public function CustomerListDelegate ( responder : Responder )
{
this.service = ServiceLocator.getInstance().getService("
roCustList");
this.responder = responder;
}
ServiceLocator.getInstance() should return a reference to the parent
class, not child class. Then how can you use getService() function to
return a reference to the remoting object? the Parent class "
ServiceLocator" defined in cairngorm does not have a property of
RemoteObject. It's the child class that we created using MXML has a
property of remoteObject.
I'm sorry for making this confusing and complicated. I just want to
know how the framework really works.
Thanks for the help again,
Larry
--- In flexcoders@yahoogroups.com, [EMAIL PROTECTED] wrote:
>
> Are you creating a business delegate class to handle the service
call? In
> the cairngorm framework, the actual work of getting the
remoteObject and
> making a request is inside a delegate. Consider, for example a
> remoteObject service which returns a list of customers with the id:
> "roCustList". Create a business delegate class called
> 'CustomerListDelegate' having this function:
>
> public function CustomerListDelegate ( responder : Responder )
> {
> this.service = ServiceLocator.getInstance().getService("
roCustList");
> this.responder = responder;
> }
>
> the call is made here:
>
> public function getCustList(): void
> {
> var call : Object = service.getCustList();
> call.resultHandler = responder.onResult;
> call.faultHandler = responder.onFault;
> }
>
> Obviously there is much more to creating a successful request/
response to a
> service call than this. You have to create a cairngorm event and
dispatch
> that event with is handled in a command class that places the
result in a
> model. I can send you a step-by-step bare bones example of all the
> required steps if you think you might benefit. I don't mind
admitting that
> I found it a bit bewildering at first, but when you get the hang of
it, it
> is a great framework.
>
>
>
>
>
>
> "Larry Liang" To: flexcoders@
yahoogroups.com
> <[EMAIL PROTECTED]>
cc:
> Sent by: Subject: [
flexcoders] How to subclass a singleton class ----
> flexcoders@yahoogroups.com cairngorm issue --
- Please help!!
> 04/27/2006 12:36
AM
> Please respond
to
>
flexcoders
>
>
>
>
>
>
>
> I'm new to Flex and have been spending a lot of time trying to
figure
> out how is part of cairngorm framework works. Please help.
>
> Cairngorm uses singleton pattern to ensure that there is only one
> instance of a class running for each app.
>
> For example, the ServiceLocator class use a static method to return
> the instance reference to you.
>
> public static function getInstance() : ServiceLocator
> {
> if ( serviceLocator == null )
> serviceLocator =
new
> ServiceLocator();
>
> return serviceLocator;
> }
>
> The documentation said that the recommended way to use this class is
> to subclass ServiceLocator and define your services, using the code
> similar to the following:
>
> <cairngorm:ServiceLocator xmlns:mx="http://www.macromedia.com/2003/
> mxml" xmlns:cairngorm="org.nevis.cairngorm.business.*" >
>
> <mx:RemoteObject id="customerDelegate" source="org.nevis.
> cairngorm.samples.login.LoginDelegate"
> result="event.call.resultHandler( event )"
> fault="event.call.faultHandler( event )">
> </mx:RemoteObject>
>
> </cairngorm:ServiceLocator>
>
> so far so good. however the documentation said Services can later be
> located, usually in a business delegate class as shown here:
> var service = ServiceLocator.getInstance().getService( "
> customerDelegate" );
>
> This is where I am confused. I just used mxml to subclass the
> servicelocator class and add a new property (remoteobject) to the
> instance of the subclass (not parent class). But when I use
> ServiceLocator.getInstance("cusomerDelegate")
>
> what I get is a reference to the parent class which is "
ServiceLocator
> " class defined by cairngorm. How can i use a reference to the
parent
> class to locate a property of the child class.
>
> I'm very confused. This may have something to do with the way that
> mxml script is compiled into actionscript object. Someone please
give
> me some ideas.
>
> By the way, I tried to subclass the ServiceLocator class in
> actionscript 2 and assign an service object to the subclass.
>
> When I use
>
> ServiceLocator.getInstance.getService('myService');
>
> The program returned saying that the service can not be found. I
> guess it kind of makes sense in that the object belongs to the
> subclass not the parent class.
>
> sorry for making this a bit long.
>
> Thanks,
>
> Larry
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.
txt
> Search Archives: http://www.mail-archive.com/flexcoders%40
yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
>
> --------------------------------------------------------------------
-------
> This e-mail message (including attachments, if any) is intended for
the use
> of the individual or entity to which it is addressed and may contain
> information that is privileged, proprietary , confidential and
exempt from
> disclosure. If you are not the intended recipient, you are
notified that
> any dissemination, distribution or copying of this communication is
> strictly prohibited. If you have received this communication in
error,
> please notify the sender and erase this e-mail message immediately.
> --------------------------------------------------------------------
-------
>
--
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
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.