Thanks Tim. :) Finally gotten the chance to get back to this, and what
you've said makes sense. Implementing it is proving somewhat troublesome,
though.

Still working with Cafe Townsend as my base, so I have a vos called User
which looks like this:

[Bindable]
    public class User
    {

/*-.........................................Properties..........................................*/
        public var id:Number;
        public var firstname:String;
        public var lastname:String;
        public var email:String;
        public var usertypeid:Number;


/*-.........................................Constructor..........................................*/
        public function User(
                            id:Number = 0,
                            firstname:String = "",
                            lastname:String = "",
                            email:String = "",
                            usertypeid:Number = 0
                            )
        {
            this.id = id;
            this.firstname = firstname;
            this.lastname = lastname;
            this.email = email;
            this.usertypeid = usertypeid;
        }


/*-.........................................Methods..............................................*/
        public function copyFrom(newUser:User):void
        {
            this.id = newUser.id;
            this.firstname = newUser.firstname;
            this.lastname = newUser.lastname;
            this.email = newUser.email;
            this.usertypeid = newUser.usertypeid;
        }

    }


I thought that was going to be fairly straight-forward to use, and
implemented it in my UserManager as so:

        [Bindable]
        public var thisUser:User;

        public function login(userDetail:ArrayCollection):Boolean {
            if (userDetail.length > 0) {
               thisUser.id = userDetail.getItemAt(0).id as Number;
               return true;
            }
            return false;
        }


(Note that I've taken all of the other assignments out of this since they're
currently commented out in my code anyway while I try and fix this one which
is throwing the error).

This gives me the error:

TypeError: Error #1009: Cannot access a property or method of a null object
reference.
---------------------------------------------------------
MATE Error: Argument type mismatch, turn on the debugger for more
information
EventType:loginEvent. Error was found in a ServiceHandlers list in file
MainEventMap
---------------------------------------------------------


So I'm guessing this refers to the following in my eventMap:

    <EventHandlers type="{LoginEvent.LOGIN}">
        <RemoteObjectInvoker instance="{userService}"
                method="doLogin"
                arguments="{[event.username, event.password, _dsn]}"
                debug="true">

            <resultHandlers>
                <MethodInvoker generator="{UserManager}"
                    method="login" arguments="{resultObject}"/>
            </resultHandlers>

        </RemoteObjectInvoker>
    </EventHandlers>


I'm just not sure what the problem actually is. If I take out the
"thisUser.id = etc" line from the login function in the userManager and
replace it with an alert of the result returned by the CFC, it works fine.
So it seems to me it must be something to do with that assignment. Any ideas
what it doesn't like about what I'm doing?

Cheers,

Seona.

2009/4/16 Tim Hoff <[email protected]>

>   ha, I was just kidding around about the freaking out thing.  So, you're
> getting close, but I would do it this way:
>
> First, you only need a userManager.  It is the model, so you don't need a
> userModel.   The userManager would have a currentUser property.  In your CFC
> result handler, call a method in the userManager that sets that currentUser
> to the lastResult.  Next, create another currentUser property in any
> presentationModel that needs the data.  Now, in your userMap, simply inject
> the currentUser from the userManager into the presentationModels.  When a
> new user is set, to the currentUser in the manager, the presentationModels
> will be automatically refreshed; through injection.
>
> <Injectors targets="{  [ UserPresentationModel, AnotherPresetationModel ]
> }">
>      <PropertyInjector targetKey="currentUser" source="{  UserManager }"
> sourceKey="currentUser" />
> </Injectors>
>
> -TH
>

Reply via email to