Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Err 1009 after a cast of event.result to my VO object  (Read 3227 times)
kouri
Courseware Beta
Full Member
***
Posts: 28


View Profile Email
« 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.
« Last Edit: November 13, 2008, 02:04:48 by kouri » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
Joel Hooks
Courseware Beta
Sr. Member
***
Posts: 146


baby steps

 - 46288188  - passport@provinsal.com  - joeltuff
View Profile WWW Email
« Reply #2 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.
Logged

http://joelhooks.com - my ramblings about developing with actionscript and python using pureMVC and django respectively.
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 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>
Logged
kouri
Courseware Beta
Full Member
***
Posts: 28


View Profile Email
« Reply #4 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
« Last Edit: November 14, 2008, 09:56:01 by kouri » Logged
Pages: [1]
Print