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  PureMVC Manifold / MultiCore Version / Re: Events on GWT on: June 19, 2009, 05:05:11
The best practice guide (Page 13, Notification vs Events) shows that Notifications should be used to communicate between PureMVC actors Mediators, Commands and Proxies.

Between Proxies and VOs and Mediators  and View Components local means like Events or direct messages/method calls of your own choice.
2  PureMVC Manifold / MultiCore Version / Re: EmployeeAdm demo for GWT. on: June 19, 2009, 04:58:07
from the same PDF file,
"The View primarily caches named references to Mediators. Mediator
code stewards View Components, adding event listeners, sending
and receiving notifications to and from the rest of the system on
their behalf
and directly manipulating their state.
This separates the View definition from the logic that controls it."

eg. Mediator acts as a front to View Components, to decouple the UI from puremvc code and creating a losely coupled system not dependent on display technology and puremvc. As a result, the Mediator should be aware of the View Component and listen to events, but the view components itself should not be dependent on any puremvc components. 
This is also how the conceptual drawing of the PureMvc architecture is shown.
3  PureMVC Manifold / MultiCore Version / Re: communication beetween viewComponents and mediator on: June 19, 2009, 01:50:39
Check out what I wrote in the other Event thread:

What do you think?
4  PureMVC Manifold / MultiCore Version / Re: Events on GWT on: June 19, 2009, 01:26:05
I solved the situation with GWT and Java not supporting events like the examples use in ActionScript with creating my own Callback interface.

In the UI Code:
submitCommand.addClickHandler(new ClickHandler(){
  public void onClick(ClickEvent event) {
  // this tells the Mediator to handle the new activity.
  Activity act = new Activity(descriptionInput.getValue(),
       typeInput.getValue(),   dateInput.getValue());

And previously in the constructor of the Mediator, the Mediator has called this method on the view to register a Callback event in the mediator.
    // add callback to be executed when new activity has been added.
    getViewComponent().setCallback(new Callback(){
public void execute(Object... params) {

Resulting in the same behaviour as in action script addEventListener.
Any comments about this solution? Any better solution found?
How does other people do this?
5  PureMVC Manifold / MultiCore Version / EmployeeAdm demo for GWT. on: June 19, 2009, 01:14:32
I found the new demo at http://trac.puremvc.org/Demo_Java_MultiCore_GWT_EmployeeAdmin/browser/tags/EmployeeAdmin_1_0 and checked out the source code because I have used the last 3 weeks reading about and to create my first puremvc based GWT application following all of the best practices.

In the sample application I found that the Mediators has been combined with view components and handølign all notification, view ui and events. Also it tightly communicate with Proxies. From all I have read in the best practices documents and forums I am a little confused when I see this.

I expected the Mediator and UI code to be separated and the UI code not to directly communicate with proxies?
6  PureMVC Manifold / MultiCore Version / Changes to observerlist when notifying observers not used. on: June 06, 2009, 05:24:20
Hello PureMVC users!
Im a new user to puremvc and have been playing with PureMVC the last week to find out how its working. I ported the puremvc4gwt loginsample to this puremvc multicore version and saw a small difference in how the code notifies observers.

From the loginsample from puremvc4gwt I found out that the StartupCommand adds two subcommands (PrepView and PrepModel) which when executed with the Startup event registers the proxy and mediators.

In the official multicore version in method notifyObservers in the View class I found that (marked in bold in the code below) the code creates a private copy of the observer list and uses this to iterate.

The issue I saw when running the loginsample with the official puremvc multicore version was that any new or changes to observersMap registered during the notification of the STARTUP was ignored.

As you see in the code below, the private copy doesnt see any new observers, but actually there has been one registered by the StartupCommand that also listens to the same Startup notification (SplashScreenMediator also listens to STARTUP command). It is present in the observermap and observers_ref but not in the array copy observers.

I did a quick change to the code, to work on the "live" list of observers_ref instead of a private copy, and this worked. Any changes to the list of observers are added to the end of the list so if any new observers are registered they are executed in the end of the iteration. This is also how puremvc4gwt does it in its code.

What is the reason behind isolation the observerlist in a private copy? Is it the loginsample that is not following best practice?
   public void notifyObservers( INotification note )
      List<IObserver> observers_ref = (List<IObserver>) this.observerMap.get(note.getName());
      if (observers_ref != null) {
      // Copy observers from reference array to working array,
                // since the reference array may change during the
                // notification loop

         Object[] observers = (Object[])observers_ref.toArray();
         // Notify Observers from the working array
         for (int i = 0; i < observers.length; i++) {
            IObserver observer = (IObserver)observers;
Pages: [1]