http://img37.imageshack.us/i/debug1.jpg/

this is debug from mediator.
loginUserData is always null :(

--- In [email protected], Simon Bailey <si...@...> wrote:
>
> Debug man, check the datatype of the object coming back from your  
> remote request, maybe there is a problem with the cast.  Is the Object  
> from your remote result datatyped?
> 
> Try assigning it to a var first and then debug to see if the cast  
> works.  If on debug you cast the result successfully and can see the  
> cast variable in debugger no problem there should be no reason why you  
> cannot then send that variable on a notification.
> 
> What is showing in the debugger in your mediator?
> 
> On 23 Jun 2009, at 15:50, vladakg85 wrote:
> 
> >
> >
> > I tried this data = evt.result as User; and its not work.
> > I also tried to send User data with notification, same again.
> >
> > LoginCommand
> > [code]
> > override public function execute(notification:INotification):void
> > {
> > var myUser:User = notification.getBody() as User;
> > var loginProxy:LoginProxy;
> > loginProxy = facade.retrieveProxy(LoginProxy.NAME) as LoginProxy;
> > loginProxy.tryLogin(myUser.username, myUser.password);
> > }
> > [/code]
> >
> > Mediator
> > [code]
> > override public function  
> > handleNotification(notification:INotification):void
> > {
> > switch (notification.getName())
> > {
> > case ApplicationFacade.LOGIN_SUCCESFUL:
> > var uProxy:LoginProxy;
> > uProxy = facade.retrieveProxy(LoginProxy.NAME) as LoginProxy;
> > var u:User = notification.getBody() as User;        
> > Alert.show("welcome: " + u.realName+ ", " + u.City);
> > break;
> > case ApplicationFacade.LOGIN_FAILED:
> > Alert.show("sorry pal, wrong password");
> > break;
> > }   
> > }
> > [/code]
> > --- In [email protected], Simon Bailey <simon@> wrote:
> > >
> > > In your onResult method try assigning the data like:
> > >
> > > data = evt.result as User; // cast result to a User Object and  
> > assign
> > > to data
> > >
> > > Then you need to either:
> > >
> > > a) Have you mediator access the loginUserData directly (you may need
> > > to set it up as Bindable and dispatch an updated event - see 
> > > http://bit.ly/14Rlqd
> > > and look at my HandleLoginProxy).
> > > b) Easier to assign the loginUserData as the notification body e.g.
> > > sendNotification( ApplicationFacade.LOGIN_SUCCESSFUL,  
> > loginUserData );
> > > and in your Mediator register an interest in the LOGIN_SUCCESSFUL
> > > notification and simply pull out the loginUserData object using
> > > note.getBody().
> > >
> > > I would go for option (b)!
> > >
> > > On 23 Jun 2009, at 14:59, vladakg85 wrote:
> > >
> > > >
> > > >
> > > > Hi, thank you so much, I did something that I was trying for whole
> > > > month :( ddd :) But now I have one more problem, this one is  
> > small :)
> > > >
> > > > 1) I make remote call to .NET to login user, everything is fine
> > > > retrive data, check if user exists its ok, data from service are  
> > in
> > > > proxy, this is my code for this:
> > > > [code]
> > > > public class LoginProxy extends Proxy implements IProxy
> > > > {
> > > > public static const NAME:String = "loginProxy";
> > > >
> > > >
> > > > private var loginRemoteService:RemoteObject;
> > > >
> > > > public function LoginProxy()
> > > > {
> > > > super(NAME, new User());
> > > >
> > > > loginRemoteService = new RemoteObject("fluorine");
> > > > loginRemoteService.source = "BL.Sample";
> > > > loginRemoteService
> > > > .LoginUserByEnteredData.addEventListener(ResultEvent.RESULT,
> > > > onResult);
> > > > loginRemoteService.addEventListener(FaultEvent.FAULT, onFault); 
> > > > }
> > > >
> > > > private function onResult(evt:ResultEvent):void
> > > > {
> > > > setData(evt.result);
> > > > sendNotification(ApplicationFacade.LOGIN_SUCCESFUL);
> > > > }
> > > >
> > > > private function onFault(evt:FaultEvent):void
> > > > {
> > > > sendNotification(ApplicationFacade.LOGIN_FAILED);
> > > > }
> > > >
> > > > public function get loginUserData():User
> > > > {
> > > > return data as User;
> > > > }
> > > >
> > > > public function tryLogin(p1:String, p2:String):void
> > > > {       
> > > > loginRemoteService.LoginUserByEnteredData(p1, p2);      
> > > > }
> > > > }
> > > > }
> > > > [/code]
> > > >
> > > > Problem is in mediator, because I send successful notification  
> > from
> > > > proxy to mediator, and I want to preview returned data  
> > ("Welcome: "
> > > > + name + username + city ... etc.), but problem is because
> > > > "loginUserData" is null. And in debug, data is full with data but
> > > > they are private so can't use it, what I have done?
> > > >
> > > > --- In [email protected], Simon Bailey <simon@> wrote:
> > > > >
> > > > > > 1) What should I do/type to store data in proxy and in what  
> > var?
> > > > Is
> > > > > > there any special var?
> > > > > >
> > > > > Typically the proxy is storing an Object with your data which
> > > > could as
> > > > > your quite rightly state, be a result from a service call of  
> > some
> > > > > type. For example, an ArrayCollection containing all your user  
> > value
> > > > > objects. The IProxy interface exposes a property named data  
> > which is
> > > > > typed as an Object, this can be cast to data type you want and
> > > > > instantiated in your Proxy class constructor, set through the  
> > data
> > > > > reference and retrieved using a simple getter (see below):
> > > > >
> > > > > public function UserProxy()
> > > > > {
> > > > > super( NAME, new ArrayCollection ); // second param is  
> > instantiating
> > > > > the data Object casting as a new ArrayCollection
> > > > > }
> > > > >
> > > > > public function assignAllUsers( val:ArrayCollection ):void
> > > > > {
> > > > > data = val; // Assign the result from a service call to our data
> > > > > array collection
> > > > > }
> > > > >
> > > > > public function get userArrayCollection():ArrayCollection
> > > > > {
> > > > > return data as ArrayCollection; // return the proxy data  
> > object as
> > > > an
> > > > > ArrayCollection
> > > > > }
> > > > >
> > > > > > 2) How to get specific data from proxy?
> > > > > >
> > > > >
> > > > > Using the public getter as shown above
> > > > >
> > > > > > 3) What is the connection between commands and proxy
> > > > > >
> > > > >
> > > > > You can use a command to interact with the proxy e.g. pass login
> > > > > information to the proxy which will send the data to a remote
> > > > service
> > > > > for verification.
> > > > >
> > > > > > 4) If I have User Proxy with ability to log in user, log out  
> > user,
> > > > > > display user name, display user details... should I put all  
> > this
> > > > in
> > > > > > one proxy or make separate:
> > > > > > loginProxy
> > > > > > getUserNameProxy
> > > > > > userDetailsProxy
> > > > > > etc.
> > > > > >
> > > > >
> > > > > Depends on what data, if we go by what you suggested i.e.  
> > username
> > > > > password and general user details then I personally would have a
> > > > > UserProxy which handles the user details as a whole.
> > > > >
> > > > > HTH,
> > > > >
> > > > > Simon
> > > > >
> > > > > [ Blog ] nutrixinteractive.com/blog/
> > > > >
> > > > > On 23 Jun 2009, at 11:34, vladakg85 wrote:
> > > > >
> > > > > >
> > > > > >
> > > > > > I try to learn this framework for a month, and I always stack
> > > > > > somewhere, and now I need help.
> > > > > > What I know: to make view, to make mediators, to make  
> > commands..
> > > > > > But, I don't understand proxy at all.
> > > > > > First what should be there. I think that this is the place  
> > where I
> > > > > > store service call methods and keep returned data from  
> > server so I
> > > > > > can use that data through every part of application (just to  
> > grab
> > > > > > them). Ok, maybe I am ok with this, but I don't know how to
> > > > > > implement this :(. 1) What should I do/type to store data in  
> > proxy
> > > > > > and in what var? Is there any special var?
> > > > > > 2) How to get specific data from proxy?
> > > > > > 3) What is the connection between commands and proxy
> > > > > > 4) If I have User Proxy with ability to log in user, log out  
> > user,
> > > > > > display user name, display user details... should I put all  
> > this
> > > > in
> > > > > > one proxy or make separate:
> > > > > > loginProxy
> > > > > > getUserNameProxy
> > > > > > userDetailsProxy
> > > > > > etc.
> > > > > >
> > > > > > Please help me to understand this framework, I am crying :(`
> > > > > >
> > > > > > Thanks, for any answer
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
>


Reply via email to