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] 2
Print
Author Topic: EmployeeAdmin - A PureMVC AS3 / Flex Demo  (Read 49419 times)
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« on: January 01, 2008, 02:20:52 »

This demo illustrates techniques for performing routine maintenance operations in a PureMVC-based Flex application.

The demo has historically been located here: http://trac.puremvc.org/Demo_AS3_Flex_EmployeeAdmin
The project has been moved here: https://github.com/PureMVC/puremvc-as3-demo-flex-employeeadmin/wiki

The author is Cliff Hall.
« Last Edit: September 23, 2012, 09:03:20 by puremvc » Logged
rbhadra
Newbie
*
Posts: 4


View Profile Email
« Reply #1 on: April 17, 2008, 03:25:30 »

Hey I am getting this error ->
"unable to load SWC PureMVC_AS3_2_0_1.swc"...can you help me out in this
Logged
Rhysyngsun
Courseware Beta
Sr. Member
***
Posts: 51

Nathan Levesque

 - rhysyngsun@gmail.com  - rhysyngsun
View Profile WWW Email
« Reply #2 on: April 17, 2008, 06:33:34 »

rbhadra, the compiler cannot find the PureMVC_AS3_2_0_1.swc file which should be located in the libs folder, however, without knowing your compile settings, I can guess that it is looking for it in the root of the project directory instead. Are you using Flex Builder or the command line compiler?
Logged

puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: April 17, 2008, 12:07:16 »

More than likely being bit by the issue with Flex Builder 3 compiler not creating a swc compatible with FB2.

In order to make the demo run in FB2, you need to download or check out the PureMVC_AS3 project source code, and set it up as a Flex Library project, and recompile the swc.

You can then replace this FB3 compatible swc with your FB2 swc, or remove the swc from your project and make the project dependent on your PureMVC_AS3 project.

-=Cliff>
Logged
petneb
Newbie
*
Posts: 1


View Profile Email
« Reply #4 on: June 21, 2008, 07:16:22 »

Hi

I was just wondering (being new to puremvc) if the lines in UserFormMediator's clearForm method that reset's the form text controls was not violating the intension of loose coupling. Allso they seem not to matter as they are bound to the user value object and therefore resets as soon as the first line is executed (userForm.user = null;).

Maybe I'm missing something but I'm just trying to get my head around the issues of coupling, message flow and what have you.

Thanks for providing some great demo apps and a great framework and sorry if I'm just being stupid.


      private function clearForm():void
      {
         userForm.user = null;
          userForm.username.text = '';
         userForm.first.text = '';
         userForm.last.text = '';
         userForm.email.text = '';
         userForm.password.text = '';
         userForm.confirm.text = '';
         userForm.department.selectedItem = DeptEnum.NONE_SELECTED;
           }
« Last Edit: June 21, 2008, 07:23:54 by petneb » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #5 on: June 21, 2008, 11:16:53 »

You're absolutely correct, this method should be refactor/moved into the component itself and invoked from the Mediator.

-=Cliff>
Logged
philm
Newbie
*
Posts: 2


View Profile Email
« Reply #6 on: July 07, 2008, 09:09:39 »

Hi - I am evaluating PureMVC for use with an upcoming project and find the demo apps quite helpful. I have a question about the Employee Demo.

I can follow pretty much the logic of what is going on in the demo but I can't seem to find where the UserList.users property is being assigned? Or, for that matter, the UserProxy.data property (which is cast to ArrayCollection in the users getter)? What and where is this array collection created and assigned to these properties?

Phil.
P.S. Congrats on the PureMVC documentation! It's amazing for an open source project!
« Last Edit: July 07, 2008, 09:35:32 by philm » Logged
Peter
Full Member
***
Posts: 26


View Profile Email
« Reply #7 on: July 08, 2008, 02:32:45 »

Look in the UserListMediator:
(which is instantiated in the StartUpCommand with:
facade.registerMediator( new UserListMediator( app.userList ) );
)

in its constructor:
userProxy = facade.retrieveProxy( UserProxy.NAME ) as UserProxy;
userList.users = userProxy.users;

The Proxy has a property 'data' which is a generic object. It receives a new ArrayCollection in:
super( NAME, new ArrayCollection );

so if you want to use that ArrayCollection you need to retrieve it as an ArrayCollection, hence:
public function get users():ArrayCollection
{
   return data as ArrayCollection;
}

which is used in:
public function addItem( item:Object ):void
{
   users.addItem( item );
}

because users is an ArrayCollection you can use ArrayCollection.addItem() there.

Hope this helps...
Logged
philm
Newbie
*
Posts: 2


View Profile Email
« Reply #8 on: July 08, 2008, 01:44:10 »

I see it now. Thanks!
Logged
ryebrye
Newbie
*
Posts: 7


View Profile Email
« Reply #9 on: July 18, 2008, 12:16:25 »

In this example, the AddRoleResultCommand will show an alert dialog if there is a role that already exists for that user.

:
public class AddRoleResultCommand extends SimpleCommand implements ICommand
    {
        override public function execute( notification:INotification ):void
        {
            var result:Boolean = notification.getBody() as Boolean;
            if ( result == false ) {
                Alert.show ('Role already exists for this user!','Add User Role');
            }
        }
       
    }

Wouldn't it be better for the Command to resend a notification to tell the rest of the system about this case?

Is it kosher for Commands to open up new windows and display things for user interaction (which is what an Alert is)?

I was under the understanding that this is typically the role of the view to display an alert, and the role of the mediator to listen for a notification and then alert the user when necessary. (The benefits of having a mediator do it are things like being able to have the user specify in a preference "don't show this alert" and have it only show it when the user wants to see it... etc)


Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #10 on: July 18, 2008, 01:43:38 »

True, if that alert were an actual dialog that needed to be mediated. That is if it were going to collect some response from the user which would be used in some way, for instance to solicit a retry.

But Alert.show is a static method and the Alert box captures no information we're concerned about. It simply puts up a modal window with a message that you dismiss. So creating a Mediator for that wouldn't really be useful since we're not going to listen to it.

-=Cliff>

Logged
marceloverdijk
Newbie
*
Posts: 6


View Profile Email
« Reply #11 on: July 22, 2008, 01:27:46 »

I have question related to this demo.

Currently the demo uses in memory data. In case I want to use SQLite what would be the best place to execute the sql statements? I assume the UserProxy.

:
// add an item to the data
public function addItem( item:Object ):void
{
// add logic here to database insert?

// when database insert successfull then also add item to users ac to display the new record in the binded view
users.addItem( item );
}

I'm wondering if the above pseudo code is the way forward, or are there any better alternatives?

Cheers,
Marcel
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #12 on: July 22, 2008, 02:28:27 »

Just as it is fine to use a proxy to fetch and update its data via a remote service, you can do sql access in your proxy as well. There was some talk on the forums of an SQLProxy that someone was building, which would be extended by concrete classes, and it would pass on some good functionality, but I'm not sure where that stands. You might want to do a little poking around here in the forums to see if you can pick up on that thread and see where it went.

-=Cliff>
Logged
marceloverdijk
Newbie
*
Posts: 6


View Profile Email
« Reply #13 on: July 23, 2008, 12:23:24 »

Thanks Cliff,

I read about this SQLProxy already and it really helped.

So the approach for doing both the sql insert and adding the item to the internal array collection is good?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #14 on: July 23, 2008, 04:37:41 »

Yes. Well, you probably want to uptadt the object with its database id after the sql insert and before sticking it in the Proxy's ArrayCollection.

-=Cliff>   
Logged
Pages: [1] 2
Print