|
|
Show Posts
|
Pages: [1]
|
2
|
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/
|
|
|
3
|
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/
|
|
|
6
|
Announcements and General Discussion / Architecture / Shared proxy in modular application?
|
on: August 05, 2009, 10:34:18
|
Hi, I am trying to create an application where main view shows users(in a list component) and cars for each user(in datagrid component). Application has 7 modules: MainDisplayModule - module with list, datagrid component and buttons 'Add User', 'Remove User', 'Edit User', 'Add Car', 'Remove Car', 'Edit Car' UserCreatorModule - module with UserCreator(popup window) component - FirstName, Age textInputs, OK and Cancel button UserEditorModule - module with UserEditor(popup window) component - FirstName, Age textInputs, OK and Cancel button UserRemoverModule - module UserRemover(popup window) component - FirstName label, OK and Cancel button CarCreatorModule - module with CarCreator(popup window) component - Make, Model, Year textInputs, OK and Cancel button CarEditorModule - module with CarEditor(popup window) component - Make, Model, Year textInputs, OK and Cancel button CarRemoverModule - module CarRemover(popup window) component - Make, Model, Year label, Ok and Cancel button Having separate modules for popups gives me States and Substates in this application  . Modules are connected with Pipes and each core(module) has its own StateMachine. I have CarsProxy with methods addCar(car:CarVO), removeCar(car:carVO), getCars(), cars() and UsersProxy with methods addUser(user:UserVO), removeUser(user:UserVO), getUsers(), users(). Proxies add, remove and retrieve records from/to MySQL server. Should I place CarsProxy, UsersProxy in a common library? I dont know but i was thinking about creating another module(ServiceModule) and connecting it with modules. Modules could send and receive messages from/to ServiceModule. Is it a good practice? Do you have a different approach? I use Flex/Multicore, StateMachine, Pipes Utility. Mariush T. http://mariusht.com/blog/
|
|
|
7
|
Announcements and General Discussion / Architecture / Application needs architecture
|
on: July 22, 2009, 09:38:14
|
I have problem with architecture of LiteFtpClient application(Flex/Multicore PureMVC, Pipes, StateMachine). You can see mockup below. Initial window  Ftp address, username, password were entered. Application is in a process of connecting to the server(logging, getting directories), popup window is visible.  User can browse through files and folders in CONNECTED mode.  'New Folder' was clicked, popup window is visible  User is able to rename files, 'Rename' button was clicked  'OK' button was clicked in 'Delete File/Folder' popup window. 'delete item' request was sent to the server, application is waiting for response from the server. Popup window is still visible, 'OK' button is disabled.  I got following questions: -should i create modules and StateMachines for each popup window? Maybe i am wrong, but i think it would be good to have FSMs(similar to that one below) for each popup window, application then can have States and SubStates.  -If i have modules for popups, when i should load them? Should i load modules one by one after user is successfully connected or maybe when for example, 'New Folder' button was clicked and popup window is about to be created. - Do you add any view components into shell application? Should shell application only be responsible for loading, unloading, connecting and disconnecting modules? -What are steps in your application development? Do you start with designing User Interfaces, Use Cases, States, etc? I started with User Interfaces(screenshots) then i worked on States. Later i created SubStates, now i need modules since i have SubStates. -How should i name modules, popup windows? DeletingModules or DeleteModule, FolderDeletingWindow...? -How do you know how many modules you need? Is there any rule? It looks like i need modules for states with substates. +--DISCONNECTED +--DISCONNECTING +--CONNECTING +--GETTING_DIRECTORIES +--CONNECTED +--CREATING +--DELETING +--INITIALIZATION +--DELETING +--CLOSING +--FAILING +--RENAMING +--UPLOADING  Am i wrong? I think i should have MainModule, BrowsingModule, DeletingModule and couple more for each popup windows. MainModule, Main FSM Diagram, user is 'DISCONNECTED'.  BrowsingModule, Below FSM diagram can only happened when user(application) is in CONNECTED state.  DeletingModule, FSM Diagram for 'Delete' popup window  -Do you know any links to real world applications with source codes, any tutorials on how to architect this type applications? I would like to to here your thoughts. NOTE!!! Above application is for my practice purpose only(not for a client) and I will be happy to share source code with the community at the end. Mariush T. http://mariusht.com/blog/
|
|
|
|
|