PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: kouri on November 13, 2008, 09:39:28



Title: Err 1009 after a cast of event.result to my VO object
Post by: kouri on November 13, 2008, 09:39:28
hello,

In a "classical" login module with a class mapped VO (freely stolen from Cliff toturial and answers to Shinan  :) ) , I return the MemberVO object representing the whole profile of user if he is known in db or return false if not.

On my LoginProxy class, everything seems ok. I can cast event.result to MemberVO class but the instance I get is null.

:
private function onResultHandler(event:ResultEvent):void{
   if (!event.result){
      setData(null);
   }else{
      trace("id="+event.result.id+"     nickname="+event.result.nickname);     //works fine! I get ID and nickname...
      setData(event.result);
      var memberVO:MemberVO=event.result as MemberVO;   //no complain !
      trace("memberVO.id="+memberVO.id)     //Error #1009: Cannot access a property or method of a null object..   
   }
   sendNotification(LOGIN_RESPONSE,event.result);
   

maybe i missed something ???
Thx for any help.


Title: Re: Err 1009 after a cast of event.result to my VO object
Post by: puremvc on November 13, 2008, 04:12:06
Is your VO being mapped properly?

Are you using Flex Builder? If so, set a breakpoint on the first line of your else block and run in debug mode. When it stops, on that line, check your variables view. Open up the event and check out what got returned. Is your VO actually it the first element of an array collection? Was it a bare object because the mapping didn't go properly? Was it null because your service didn't return anything? You'll see in an instant.

Also, if you don't use the debugger much, when you open the event in the variables view, you may need to drop down the little down-arrow menu to the right of the variables view panel and select Flex->Show Inaccessable Member Variables.

-=Cliff>


Title: Re: Err 1009 after a cast of event.result to my VO object
Post by: Joel Hooks on November 13, 2008, 09:43:37
It might also be helpful to run a monitor like Charles to see what is coming back from the service.

Also, I've found that I have to create an instance of my VOs in the root of my application:

<vo:MyVO />

or AMF doesn't want to recognize the typed object. Casting an object as will return null if the type isn't correct, so I'd assume that is the problem. Something about the signature doesn't match.


Title: Re: Err 1009 after a cast of event.result to my VO object
Post by: puremvc on November 14, 2008, 06:02:58
@joel It dosent have to be at the root or even an instance. Just doing var MyVO:MyVO; is enough to ensure Fle compiles the class in. But he's doing a cast, so that should be enough.

-=Cliff>


Title: Re: Err 1009 after a cast of event.result to my VO object
Post by: kouri on November 14, 2008, 09:48:17
The $_explicitType of my PHP vo was effectively wrong !  :-\ Shame on me !!
That works great now.

I understand that vo props can be obtained without having a proper class mapping. Good to know.

Thanks to you two. ;)

Eric