PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: justSteve on March 31, 2008, 03:19:43



Title: Where to put ItemRenderers?
Post by: justSteve on March 31, 2008, 03:19:43
Just finished reading Peter Ent's itemRenderers: Part 4: States and Transitions (http://weblogs.macromedia.com/pent/) outlining a really clear way to handle a lot of what my menus' buttons have to deal with - state and showing or hiding other elements depending on that state.

But the renderer as presented in that specific demo seems impossible to implement in Purely MVC fashion. Is it a matter of breaking the different code elements to respective roles? As presented it's soooo nice and tidy.

Do we have itemRenderers exhibited in any demos?

thx
--steve...


Title: Re: Where to put ItemRenderers?
Post by: puremvc on March 31, 2008, 11:58:25
Hi Steve,

What problems are you having specifically?

I have one on the back burner. But what problems specifically are you having? Aside from the normal fact that item renders stink in Flex?

-=Cliff>


Title: Re: Where to put ItemRenderers?
Post by: justSteve on April 01, 2008, 03:51:27
The problem is getting my head around the division of labors involved. A view looks to a controller for it's info but it looks as though in Ent's code the view (dataitemRenderer) is poking directly into the model.
>>
The set data function determines which state to use by looking at the value of instock:
      override public function set data( value:Object ) : void
      {
         super.data = value;
         
         if( data )
         {
            if( data.instock == "yes" )
               currentState = "";
            else
               currentState = "NoStockState";
         }
      }
>>



Title: Re: Where to put ItemRenderers?
Post by: puremvc on April 02, 2008, 07:50:33
In the item renderer, 'data' is the property of the specific data being rendered. This comes from the view component (DataGrid, List, etc) it is rendering an item for.

Here's a scenario to clear things up:

  • On receiving data from a service, a Proxy could send a Notification with a reference to its ArrayCollection of VOs.
  • A Mediator might hear this and set that ArraryCollection as the dataProvider of the DataGrid component it is stewarding.
  • The DataGrid might have a custom ItemRenderer it uses to display a given field.
  • That ItemRenderer's 'data' property would be the VO being displayed in its row of the DataGrid.
  • The ItemRenderer could examine any or all fields of that VO in order to determine how to behave and what to display.

Hope this helps,
-=Cliff>


Title: Re: Where to put ItemRenderers?
Post by: justSteve on April 02, 2008, 08:01:23
I does help...thankx much.