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

Pages: [1]
Print
Author Topic: Best way to take single view to multiple views  (Read 3460 times)
codecraig
Full Member
***
Posts: 23


View Profile Email
« on: September 24, 2008, 06:36:43 »

I currently have a rather complex UI.  In it there is a particular view which has its own Proxy, Mediator and view components, but now I need to allow the user to multiple displays of it.  So instead of a single view, maybe I use a tabbed style view.

For example, say this view displays stats about ONE baseball team.  It lists players, batting averages, win/loss, etc.  If they want to look at another team there is a combo box and they select a team and click "update" and the view updates.

Now, I need to have N-number of these views displayed for different teams.  So, if I did a tabbed view they could have 3 tabs (for example), each tab displays stats for a different team.

Is there a recommended approach to refactoring my code to support this?  Right now it's all based on getting data and displaying data for one team.  Now it seems like I need a parent proxy (which handles giving data about a team to the correct child proxy) and a parent mediator and a parent view.

What do you think?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: September 24, 2008, 07:19:10 »

I don't know that I'd have a separate proxy for each team's stats. I'd expect one proxy that has an arraycollection of VO's of team stats. If there are three VO's of team stats then the ArrayCollection could be a data provider for a custom tab navigator component which could show a tab for each VO. Keep in mind that ArrayCollection can have a dynamic filter applied to it, changing the set of VOs in the list and thus the number of tabs displayed. Since ArrayCollections automatically inform the view components for which they are data providers, it leverages Flex's own data-aware view components. You may only need the custom tab navigator component and a mediator for it (and not one for each child if its display only).

Otherwise, you can do this the classical way of instantiating a mediator for each tab and ensuring it gets the data it needs for its view component.

-=Cliff>
Logged
Pages: [1]
Print