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: Generate some test data  (Read 2612 times)
mariusht
Full Member
***
Posts: 26


View Profile Email
« 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/
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 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>
Logged
Pages: [1]
Print