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] 2
1  Announcements and General Discussion / Public Demos, Tools and Applications / Member Database - AIR/Flex/PureMVC on: March 24, 2010, 07:27:58
I just created 'Simple Member Database' application. This demo illustrates how you can use Flex, PureMVC and Adobe AIR local SQL database to create simple member management system.

http://mariusht.com/blog/2010/03/23/memberdatabase-air-application-flex-puremvc/

Mariush T.
http://mariusht.com
2  Announcements and General Discussion / Architecture / Re: StateMachine Action Notification Chains Problem on: February 02, 2010, 07:49:32
:
The problem is that my ChangedModuleInitingCommand initiates the transition to MODULE_PLAYING by sending a notification of CHANGE and type MODULE_INIT_DONE
Your ChangedModuleInitingCommand should
sendNotification(StateMachine.ACTION, null, ShellFacade.MODULE_INIT_DONE);


Mariush T.
http://mariusht.com/blog/
3  Announcements and General Discussion / Architecture / Re: What is considered the best practice for adding viewComponents to the stage? on: February 01, 2010, 07:42:45
Command may register, retrieve and remove another Proxy or Mediator

Look at my blog post http://mariusht.com/blog/2009/05/28/puremvc-actors-and-their-responsibilities/

Mariush T.
http://mariusht.com/blog/
4  Announcements and General Discussion / Architecture / Re: What is considered the best practice for adding viewComponents to the stage? on: January 30, 2010, 02:17:33
Go with:
...send a notification with a reference to the timeline viewComponent as its body. Then the ApplicationMediator would handle that note and add it to stage.

You don't want to make dependencies between mediators in you application.

Mariush T.
http://mariusht.com/blog/
5  PureMVC Manifold / MultiCore Version / Re: Custom Messages - my code looks cleaner now on: January 21, 2010, 09:56:30
Imajn looks interesting. I signed up for beta test program.

Mariush T.
http://mariusht.com/blog/
6  PureMVC Manifold / MultiCore Version / Custom Messages - my code looks cleaner now on: January 20, 2010, 09:41:04
Hi Cliff,

You can see here handlePipeMessage method from PipeWorks demo (LoggerJunctionMediator.as)
:
override public function handlePipeMessage( message:IPipeMessage ):void
        {
            if ( message is LogMessage )
            {
                sendNotification( ApplicationFacade.LOG_MSG, message );
            }
            else if ( message is UIQueryMessage )
            {
                switch ( UIQueryMessage(message).name )
                {
                    case LoggerModule.LOG_BUTTON_UI:
                        sendNotification(ApplicationFacade.CREATE_LOG_BUTTON)
                        break;

                    case LoggerModule.LOG_WINDOW_UI:
                        sendNotification(ApplicationFacade.CREATE_LOG_WINDOW )
                        break;
                }
            }
        }

and the source code for one of your custom messages
:
package org.puremvc.as3.multicore.demos.flex.pipeworks.common
{
    import mx.core.UIComponent;
   
    import org.puremvc.as3.multicore.utilities.pipes.messages.Message;

    public class UIQueryMessage extends Message
    {
        public static const GET:String = 'get';
        public static const SET:String = 'set';
       
        public function UIQueryMessage( action:String, name:String, component:UIComponent=null)
        {
            var headers:Object = { action:action, name:name };
            super( Message.NORMAL, headers, component );
        }
       
        public function get action():String
        {
            return header.action as String;
        }

        public function get name():String
        {
            return header.name as String;
        }

        public function get component():UIComponent
        {
            return body as UIComponent;
        }
       
    }
}

Below you can see one of my custom messages and the way i access their types in any JunctionMediator

:
package com.mariusht.contactmanager.common.messages
{
import com.mariusht.contactmanager.common.model.vo.ContactVO;

import org.puremvc.as3.multicore.utilities.pipes.messages.Message;

public class ContactMessage extends Message
{
protected static const NAME:String = 'ContactMessage';

public static const ADD_CONTACT:String = NAME + '/message/contact/add';
public static const CONTACT_ADDED:String = NAME + '/message/contact/added';
public static const CONTACT_ADD_FAILED:String = NAME + '/message/contact/add/failed';

public static const UPDATE_CONTACT:String = NAME + '/message/contact/update';
public static const CONTACT_UPDATED:String = NAME + '/message/contact/updated';
public static const CONTACT_UPDATE_FAILED:String = NAME + '/message/contact/update/failed';

public static const REMOVE_CONTACT:String = NAME + '/message/contact/remove';
public static const CONTACT_REMOVED:String = NAME + '/message/contact/removed';
public static const CONTACT_REMOVE_FAILED:String = NAME + '/message/contact/remove/failed';

public function ContactMessage(type:String, contact:ContactVO=nulll)
{
                        // add headers if needed
super(type, null, contact);
}

public function get contact():ContactVO
{
return body as ContactVO;
}
}
}

JunctionMediator.as
:
override public function handlePipeMessage(message:IPipeMessage):void
{
switch(message.getType())
{
case ScreenMessage.GET:
//
break;
case ContactMessage.CONTACT_ADDED:
contactsProxy.addContact( ContactMessage(message).contact );
break;
case ContactMessage.CONTACT_UPDATED:
contactsProxy.updateContact( ContactMessage(message).contact );
break;
case ContactMessage.CONTACT_REMOVED:
contactsProxy.removeContact( ContactMessage(message).contact );
break;
case ItemMessage.ITEM_ADDED:
itemsProxy.addItem( ItemMessage(message).item );
break;
case ItemMessage.ITEM_UPDATED:
itemsProxy.updateItem( ItemMessage(message).item );
break;
case ItemMessage.ITEM_REMOVED:
itemsProxy.removeItem( ItemMessage(message).item );
break;
}
}

I really like using 'switch case' rather 'if, else if' statements in handlePipeMessage method. It makes my code cleaner.

Let me know what you think.

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

7  Announcements and General Discussion / Fabrication / Re: trap/reacTo not working (fabrication 0.6) on: January 19, 2010, 09:22:40
You should NOT access properties on component's children. This is a BAD PRACTICE.

LoginScreenMediator.as
var user:UserVO = new UserVO();
user.username = loginScreen.txtUsuario.text;
user.password = loginScreen.txtSenha.text;

create public properties that are considered the 'API' exposed to the mediator. Inside the view component, bind the text fields (or whatever subcomponents) data to these properties such that when an event is dispatched, the mediator inspects these API fields (not the text boxes).
by Cliff
http://forums.puremvc.org/index.php?topic=369.0

you would have something like this:
:
var user:UserVO = new UserVO();
user.username = loginScreen.username;
user.password = loginScreen.password;

Mariush T.
http://mariusht.com/blog/
8  Announcements and General Discussion / Architecture / Re: Pipes, STDOUT - limits in current practice on: January 12, 2010, 11:13:53
The Playlist sometimes wants to talk to the VisualsModule only, which it does on a pipe named the same as the VisualsModule.NAME.

Does it make dependencies between VisualsModule and PlaylistModule? I thought modules should know nothing about other modules.

Mariush T.
http://mariusht.com/blog/
9  PureMVC Manifold / MultiCore Version / Re: Notifications in multicore? on: January 06, 2010, 01:30:12
You have to use either Pipes or Interfaces in your multicore application.

To use the above example, I feel that if LoginProxy were to interact with CoreB's mediator by calling CoreBMediator.loginSuccessfull(true) would mean that LoginProxy would have to know about CoreB's mediator or any other interested mediator elsewhere.

Proxies DO NOT interact with Mediators or Commands. Proxies send notifications. Mediators listen for these notifications.

Look at the diagram i made: http://mariusht.com/blog/2009/05/28/puremvc-actors-and-their-responsibilities/

Mariush T.
http://mariusht.com/blog/
10  PureMVC Manifold / MultiCore Version / Re: Notifications in multicore? on: January 06, 2010, 11:30:11
No, Don't do that. You would send a Message if you are using Pipes utility in your app.

Mariush T.
http://mariusht.com/blog/
11  PureMVC Manifold / MultiCore Version / Generate some test data 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/
12  Announcements and General Discussion / Architecture / Re: Q:a Searchable Photo Gallery on: December 27, 2009, 08:40:14
PhotoVO would represents a single photo.

My suggestion to your project:
Use 'PhotosProxy' instead of 'PhotoProxy'. Sometimes you can think about the proxy as a representation of your table.
You have the table 'Photos' with columns: 'id', 'filename', 'type', 'size', 'date' and maybe 'keywords'.
I would create PhotosProxy with methods:
getPhotos(date:String, tags:String) - returns XML(only photos with the same date and keywords), PhotosProxy converts retrieved XML into arrayCollection of photos(single VOs) and sends note PhotosProxy.PHOTOS_RETRIEVED

You need one more method getPhotoDetails(photo:PhotoVO) - returns information about a specific photo, PhotosProxy sends note PhotosProxy.PHOTO_RETRIEVED

public function PhotosProxy()
{
super(NAME, new ArrayCollection);
}

public function get photos():ArrayCollection
{
return data as ArrayCollection;
}

public function getPhotos(date:String, tags:keywords):void
{
//call service to get photos
}

private function photosResults(event:Event):void
{
//convert XML into arrayCollection of PhotoVO
sendNotification(PHOTOS_RETRIEVED, photos);
}

public function getPhotosDetails(photo:PhotoVO):void
{
//call service
}

private function photoResult(event:Event):void
{
//convert XML into PhotoVO
sendNotification(PHOTO_RETRIEVED, photo);
}

You can add getPhotoDetails(photo:PhotoVO) to PhotosProxy or you can create a separate proxy 'PhotoProxy'.
It all depends on your project. I would create PhotoProxy in case where for example by clicking 'edit' button i open a dialog box(DialogBox, DialogBoxMediator). This mediator needs to know currently selected photo. dialogBoxMediator would get data from photoProxy.photo.

Mariush T.
Freelance Flex Developer
http://mariusht.com/blog/

13  PureMVC Manifold / MultiCore Version / Re: Call the proxy methods through JunctionMediator? on: November 19, 2009, 05:50:36
It makes sense, thank you.

Mariush T.
http://mariusht.com/blog/
14  PureMVC Manifold / MultiCore Version / Call the proxy methods through JunctionMediator? on: November 19, 2009, 07:47:29
Hi,

I would like to know if calling proxy methods through JunctionMediator is a good practice?

Scenario 1:
I send a message to the module, junctionMediator receives a message and call proxy methods.

Scenario 2:
I send  a message to the module, junctionMediator receives a messages and sends out note. Corresponding command is triggered which call proxy methods.

Thank You,
Mariush T.
http://mariusht.com/blog/
15  Announcements and General Discussion / Public Demos, Tools and Applications / NoteList - text notes manager on: November 13, 2009, 04:10:57
I want to share my latest application - NoteList - text notes manager.

It's an Adobe AIR application built on PureMVC(Multicore with Pipes) framework.

Why i built it?
I used to write my thoughts(notes) in text files, but after a while i had to many files all over my hard disk and it was hard to find what i was looking for. I wanted simple way to manage my thoughts :).

I encourage you to install and try it on your own.
http://mariusht.com/products/notelist/

I appreciate your Feedback!

Cliff, once again thank you for PureMVC framework.

Mariush T.
http://mariusht.com/blog/
Pages: [1] 2