PureMVC Architects Lounge

Announcements and General Discussion => Getting Started => Topic started by: DavidPesta on September 29, 2009, 04:44:09



Title: Big Picture Question about Views
Post by: DavidPesta on September 29, 2009, 04:44:09
Hello Everyone

Beginner question here.

If I want a view of a panel with a large list of items that needs a scrollbar, the whole thing should be one view, right? The scrollbar should not be its own separate view, but rather be a part of the same view as the panel and the items inside of that panel. Granted, the scrollbar would exist in its own class. (I'm guessing Flex has a scrollbar, but I'm more interested in pure actionscript.)

So a view is used to represent a chunk of interface functionality where several widgets are related to the same task and are working together. We should not have a separate view for every single widget in the assembly.

So, do I have all this understood correctly?

Thanks!
David


Title: Re: Big Picture Question about Views
Post by: Jason MacDonald on September 29, 2009, 06:05:47
More or less, that's right. You only need to mediate where data is being fed into a component or view. A ScrollBar doesn't have data, per-say (by data I mean information coming from a backend). For instance, if you had a list control, you could mediate the list because you are likely to feed data from the backend into the list. There's no need to mediate the scrollbar on the list, the list control handles that and keeps it's logic encapsulated within the control.


Title: Re: Big Picture Question about Views
Post by: Helmut Granda on September 29, 2009, 06:22:22
Just out of curiosity. Who are you referring to when you say "Control" are you talking about any specific kind of class within puremvc?


Title: Re: Big Picture Question about Views
Post by: mariusht on September 29, 2009, 03:58:26
Jason is referring to Flex List Control.

As you may know, Flex comes with variety of components:
Controls: Button, Label, LinkButton, List, Tree...
Layout: Canvas, Tile, VBox...
Navigators: LinkBar, TabNavigator...

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


Title: Re: Big Picture Question about Views
Post by: DavidPesta on September 29, 2009, 07:02:35
Okay, so once I have my custom panel class with all the gadgets ready for action, I want my view to inherit from this panel class. Is this the best way to go? In all the examples I've seen so far (not a whole lot), the view always inherits from Sprite. But it's okay for the view class itself to inherit from another class, right?


Title: Re: Big Picture Question about Views
Post by: Helmut Granda on September 29, 2009, 09:28:25
Jason is referring to Flex List Control.

As you may know, Flex comes with variety of components:
Controls: Button, Label, LinkButton, List, Tree...
Layout: Canvas, Tile, VBox...
Navigators: LinkBar, TabNavigator...


I see, some of us use the framework without Flex, that is why I was a little confused ;)


Title: Re: Big Picture Question about Views
Post by: puremvc on September 30, 2009, 08:55:38
Have a look at the PureMVC Flex Employee Admin demo. It is a good introduction to how to divide the work in the view into separate components and how to mediate those components so that they can collaborate on various use cases like adding employees and roles.

http://trac.puremvc.org/Demo_AS3_Flex_EmployeeAdmin
-=Cliff>


Title: Re: Big Picture Question about Views
Post by: Jason MacDonald on September 30, 2009, 08:59:50
The best way I find is to have a view/component that exposes public methods for feeding data into the sub components. Then have a mediator mediate that component. This allows you to keep the inner workings of the child components encapsulated within the view component.

Of course, if your main component becomes really big, or a sub component is a candiate for being mediated on it's own, the main component mediator can create another mediator to handle that sub component by passing the child into the viewComponent param of the new mediator.

Okay, so once I have my custom panel class with all the gadgets ready for action, I want my view to inherit from this panel class. Is this the best way to go? In all the examples I've seen so far (not a whole lot), the view always inherits from Sprite. But it's okay for the view class itself to inherit from another class, right?

The view component can extend, or be, any valid decendant of DisplayObject (Sprite, DisplayObjectContainer, MovieClip etc).