One of the joys of Mate is that you can create a 'Services' component set to fx:object and set up all your data services (web services) and give them ID's and the wsdl address, then, in your map per eventhandler call a different method on that web services via the WebServicesInvoker. Then depending on what Manager you want to tweek the data, call then in the resultsHandler and MethodInvoker. Focus on creating custom events to handler different scenerios of data needs. You can also create an EventHandler that invokes other EventHandlers to set up multiple data needs per view.

Lets say you have a email client where you need all messages and emailaddresses (for a phonebook). Rather than having the view fire off multiple events to retrieve the different datas, you can have a single Event (MessengerEvent.START) and in your EventHandler, have it perform multiple single event calls.

<EventHandlers type="{MessengerEvent.START}">
<EventAnnouncer type="{MessEvent.LIST}">
<Properties username="{event.username}" />
</EventAnnouncer>
<EventAnnouncer type="{PhoneBookEvent.LIST}">
<Properties username="{event.username}" />
</EventAnnouncer>
</EventHandlers>

This way you can preserve the individual Events incase another view needs only one. For example another view just wants the phone book, it can just call the PhoneBookEvent.LIST event and have that view be binded to that ArrayCollection also.

A manager is just there to tweek the data and put it into a dataholder. It doesn't care where it goes to or how many elements are using it. As long as it can support it.

Split your managers up by category and you can have as many as you like. I break mine up by view (or view category). For my child portal application I have ChatManager, ArtManager, UserManager, UsageManager, JournalManager, MailManager, AppManager, and about a dozen others. Don't make a generic manager that handler EVERYTHING, especially if you are talking over 100 views.

Also, as your EventMap grows, break it up into other EventMaps. I have mine by Event type letters (A-L, M-R, S-Z). For Example MailEvent goes in M-R, JournalEvent goes in A-L, etc.

Hope that helps. If you need anything else. Let me know. I can share what knowledge I have.

On 4/20/2010 2:55 PM, md_ars wrote:



Thanks Wally. It worked. I don't know where I was missing. I started from the same because with one panel I tested it successfully to populate data in a DataGrid. When I added multiple modules and menu, I modified DataManage and might have missed either some sequence or properties.

I am using only one menu which is the starting page. Main Application call this page(view as this page and Eventmap) then event is dispatched from this module to get the data for menu. I have added addEventListener(MenuEvent.ITEM_CLICK,onMenuClick) to call the other modules(component) attached to menu items. Hope this is appropriate. Now my concern is every called module(mxml component) as well as menu using the same webservice and same method with different arguments. Does this need a separate event handler for each module(component) as it is doing for menu(given below) and in the SAME eventmap. Do I need to write a separate method in DataManger for each result handler. One module may have more than one operation (fetch and save). My worry is it will become huge if I add 150 screens and 100 reports. Is there any way to make event handler generic and same with DataManger. Please suggest. I am new to both OOP and Flex.

<EventHandlers type="{GetDataEvent.GET_M}" debug="true">
<WebServiceInvoker wsdl="http://10d/MyApps/App?WSDL <http://10d/MyApps/App?WSDL>"
method="mtExecute"
arguments="{[SessionManager.dbSessionID, event.dbParam]}"
debug="true">
<resultHandlers>
<!-- parse the results -->
<MethodInvoker generator="{DataManager}" method="saveMenuData"
arguments="{resultObject}" />
<EventAnnouncer generator="{GetDataEvent}" type="{EventSequenceDispatcher.EVENT_FINISHED}" />
</resultHandlers>
</WebServiceInvoker>
</EventHandlers>

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>, Wally Kolcz <wko...@...> wrote:
>
> If you created an ArrayCollection in your DataManager, did you set it to
> [Bindable]? The AC doesn't care where it is injected or into what
> element (as long as it supports it), its just a data wrapper. Is the
> menu a separate component that you 'include' in multiple views or are
> you creating a new menu in each view? If you share a component Menu,
> then you would just need to add a Bindable arraycollection in the
> script area of your Menu then (in your EventMap) add an injector to bind
> it to the AC in the manager.
>
> For Example:
> DataManager: [Bindable] public var sourceData:ArrayCollection;
> Menu Component: [Bindable] public var menuData:ArrayCollection;
>
> <Injectors target="{MyMenuComponent}">
> <PropertyInjector source="{DataManager}" sourceKey="sourceData"
> targetKey="menuData" />
> </Injectors>
>
> If you have a menu in 2 different views (not recommended), just create 2
> injectors.
> DataManager: [Bindable] public var sourceData:ArrayCollection;
> View 1: [Bindable] public var menuData:ArrayCollection;
> View 2: [Bindable] public var menuData:ArrayCollection;
>
> <Injectors target="{View1}">
> <PropertyInjector source="{DataManager}" sourceKey="sourceData"
> targetKey="menuData" />
> </Injectors>
> <Injectors target="{View2}">
> <PropertyInjector source="{DataManager}" sourceKey="sourceData"
> targetKey="menuData" />
> </Injectors>
>
> In any case, you only need one EventMap for an application (unless you
> want to break it up to make it smaller cause they can get QUITE long).
> You would need multiple injectors (one per view) unless you create a
> component out of all shared pieces (which promotes reuse...a true OO
> best practice).
>
> Let me know if this helps at all
>
> On 4/20/2010 12:56 PM, md_ars wrote:
> >
> >
> >
> > Thanks for the reply.
> >
> > Please check my requirement below and let me know do I need separate
> > event map for each screen/mxml component? how it will be linked to
> > main event map.
> >
> > I created a ArrayCollection in the DataManager that is being populated
> > in the result event and I want to inject it in the calling module.
> >
> > -- The main application calling the view which contains the menu bar.
> > It dispatches the event. Once event is triggered and fetched the data
> > from database, control should come back to view and menu should be
> > populated with database value(menu items). The intermediate
> > ArrayCollection is being populated but not assigning values to the
> > dataprovider of menu.
> >
> > Ars
> >
> > --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>, Wally Kolcz <wkolcz@> wrote:
> > >
> > > I use Mate on all my projects. I use a lot of injectors to push my data > > > to my views by binding them to the manager Class. What is the issue you > > > are having? If you are reusing the same element on 2 views, you'd need
> > > to either put the data binding (ArrayCollection, Object, etc) on the
> > > component with your menu or push the data to both views to have the
> > menu
> > > use it as a datasource.
> > >
> > > I particularly like Mate for 2 main reasons. Lower learning curve and
> > > you don't put any of the framework into your views or models. All is
> > > managed by custom events and the map. So, if at any time in the future, > > > you want to pop it out of the application, its minimal work (just have
> > > to write connectors for the events).
> > >
> > > On 4/19/2010 1:55 PM, md_ars wrote:
> > > >
> > > > Hello,
> > > >
> > > > We are planning to use MATE framework for our project. We will have > > > > two separate applications our main transaction application will have > > > > probably over 150 screens and 100 reports. The application is mostly
> > > > data driven and we are using web-services to display and enter the
> > > > data. I tested the MATE frame work with one screen and it was easy to
> > > > implement. Now I am trying with one MENU and two screens and it is
> > > > getting complicated to use shared classes etc. Is the MATE framework
> > > > good for our application? If yes what is the best way to implement
> > > > MATE? With two screens I am already finding tricky to use Injectors.
> > > > The main code structure of my project looks like as given below.
> > > >
> > > > Main -- Contains Application module
> > > > view
> > > > Forms -- Contains screens based on panels/vbox or mdi window
> > > > Events - Contains main event map and following folders
> > > > Session -- Events triggered from the screens.
> > > > EventManager -- Parsing the data after session events fetched data
> > > > through web service.
> > > > ControlClass -- Common classes used for screens etc.
> > > >
> > > > Should I use a common structure of the whole application or should it > > > > a separate for each screen? To me it will be too messy to have common > > > > structure whereas too tedious for each screen. So far team size is 2
> > > > and may extend to 3. Please suggest an optimum way.
> > > >
> > > > Thanks
> > > > Ars
> >
>



Reply via email to