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: Beginner question about best practices for view component  (Read 7337 times)
WillyCornbread
Jr. Member
**
Posts: 11


View Profile Email
« on: April 16, 2010, 04:17:10 »

Hi -

I have a beginner view question as I dive through PureMVC....

I'm working in a Flash environment and as such my mediators actually create their viewcomponents themselves in their constructor. However, in an effort to keep my view components from knowing anything about PureMVC I find myself always creating empty viewcomponent constructors - then adding a 'renderContent' type method that I call from the onRegister of the mediator and have to pass in a great deal of info to my view component (stylesheets, messaging strings, configuration details etc). I have a nagging feeling there is a better way??

To recap:

+ View mediator is created and registered in a command.
+ View mediator creates it's view component in the constructor.
+ In the onRegister of the mediator, I retrieve several proxies (site configuration, stylesheet, etc) and then pass some values from these proxies in to a 'renderContent' method that then draw the contents of the view.
+ View component is added to stage via notification to an application mediator.

Is there a better or more accepted way to draw the components yet keep them from touching the framework themselves?

Thanks in advance!

b
Logged
WillyCornbread
Jr. Member
**
Posts: 11


View Profile Email
« Reply #1 on: April 16, 2010, 05:25:50 »

A little more info - from reading other forum posts i've found, it seems I should not be creating my view component in the mediator constructor, but on the onRegister at which time I could pass the data retrieved from the proxies, therefore removing the need for the extra 'renderContent' method.

?
b
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: April 18, 2010, 03:59:06 »

If the creation and feeding of this view component is particularly complex or cumbersome, then create it in the command and then pass that into the mediator when you create it, rather than inside the mediator itself.

Otherwise it sounds ok.
-=Cliff>
Logged
Pages: [1]
Print