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

Show Posts

| * |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Where to place flex validators? on: June 26, 2008, 05:48:57
We have a flex application with many screens, and need to programmatically run all validators in all screens, before doing a specific server action. Hence, we need to have all validators registered somewhere central, to be able to iterate them and execute validate on each. Only if all answer OK, will we execute the rest of the command. The problem is:

* a flex validator is a view-thing: It is defined in mxml, and heavily bound to a specific input field
* the action, which needs to check all validators before executing logic, shall be in a command, as it is business logic

So, where do we place the validators? We can see at least two solutions:

1) Let mediators "register" their validator instances, by putting them into the model in a list, somewhere

This way the command can easily access them all. Bad thing is, that it seems wrong, to keep references to validators in ones model. Maybe this can be made a bit better, by hiding them through some model interface.

or,

2) Let command retrieve all mediators by name, and execute a validation on each, possibly through an interface, if the particular mediator implements that validator interface.

But is it good to have a command retrieve mediators?

Which one is best? Are there other, better solutions to this problem?
2  Announcements and General Discussion / Getting Started / StartupCommand or put it in ApplicationFacade.startup() ? on: June 11, 2008, 01:35:47
I was wondering, why we are always doing a StartupCommand, which kind-of bootstraps the whole mediator and proxy setup? Couldn't we just do it directly in the ApplicationFacade.startup method?

Could this StartupCommand:

:
public class ApplicationStartupCommand extends SimpleCommand {
    override public function execute(notification : INotification) : void {
        facade.registerProxy(new XyzProxy());
        var app : FooApp = notification.getBody() as FooApp;
        facade.registerMediator(new BarMediator(app.bar));
        sendNotification(ApplicationFacade.GET_INITIAL_DATA);
    }   
}

not simply be replaced by this code, in the ApplicationFacade.startup method:

:
  public function startup(app : FooApp) : void {
      registerProxy(new XyzProxy());
      registerMediator(new BarMediator(app.bar));
      sendNotification(ApplicationFacade.GET_INITIAL_DATA);
  }

?
Pages: [1]