PureMVC Architects Lounge

PureMVC Manifold => MultiCore Version => Topic started by: mariusht on January 06, 2010, 10:14:14



Title: Generate some test data
Post by: mariusht on January 06, 2010, 10:14:14
Hi,

For SingleCore Version:
I would add some test data in UserProxy constructor like this:
public function UserProxy( )
        {
            super( NAME, new ArrayCollection );

            // generate some test data           
            addItem( new UserVO('lstooge','Larry', 'Stooge', "larry@stooges.com", 'ijk456',DeptEnum.ACCT) );
            addItem( new UserVO('cstooge','Curly', 'Stooge', "curly@stooges.com", 'xyz987',DeptEnum.SALES) );
            addItem( new UserVO('mstooge','Moe', 'Stooge', "moe@stooges.com", 'abc123',DeptEnum.PLANT) );
        }


Application doesn't work when i try to do the same thing for Multicore Version.

Do you add some test data in onRegister() method? like this:
private function onRegister():void
{
            // generate some test data           
            addItem( new UserVO('lstooge','Larry', 'Stooge', "larry@stooges.com", 'ijk456',DeptEnum.ACCT) );
            addItem( new UserVO('cstooge','Curly', 'Stooge', "curly@stooges.com", 'xyz987',DeptEnum.SALES) );
            addItem( new UserVO('mstooge','Moe', 'Stooge', "moe@stooges.com", 'abc123',DeptEnum.PLANT) );
}

It seems to be working this way.

Mariush T.
http://mariusht.com/blog/


Title: Re: Generate some test data
Post by: puremvc on January 08, 2010, 10:22:28
Pretty much everything needs to happen in onRegister instead of the constructor in MultiCore. Without seeing the error message you're receiving, I can't tell what the problem is.

The main reason for errors happening from constructor activity in MultiCore is that the Notifier in question (a Mediator, Command or Proxy) doesn't have access to its facade until after initializeNotifier has occured. That happens after construction and before onRegister. So you can put stuff either place, but it's best to wait until onRegister to manipulate the facade, so you'll be registered to participate in any notification conversations that may ensue as a result. This actually makes it a best practice for Standard as well, and so the EmployeeAdmin demo needs to be updated to reflect this.

But I don't know why simply adding to the data object would cause a problem.

-=Cliff>