tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/910-presentation-model-pattern-with-robotlegs-and-popup-windowsRobotlegs: Discussion 2012-06-29T09:25:17Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/158452912012-05-08T10:33:21Z2012-05-08T11:07:46ZPresentation Model Pattern with Robotlegs and Popup Windows<div><p>I am using Robotlegs 1.5.2 and the Presentation Model design
pattern for my new Flex application instead of MVCS. In my
implementation, the view components have a presentation model (PM)
injected into them (injection defined in the Context) and the PM
has no reference to the view. The presentation model classes
implement “Actor” and short-lived commands implement
“Command”. I do not use the Mediator class since I am
not implementing MVCS. Implementing as described above, I am unable
to get popup windows (using the PopUpManager in my view) to have a
presentation model injected even though I did define view mappings
in my Context file (using viewMap). Is this because Flex creates
the popup outside of the context view’s display list? If so,
is there a way for me to get Flex to use the same context when
creating popups as that used by Robotlegs? Any recommendations
would be appreciated. Or can I not really implement PM and use
popups from my views using Robotlegs? I tend to like this pattern
because the view is bound to its model and changes to it are
immediately reflected in the view.</p>
<p>The approach I am following is basically the same implementation
as defined by Piotr Walczyszyn and his implementation of the
Presentation Model design pattern using Robotlegs that he presented
at Adobe MAX 2010 (implementation located at <a href=
"https://github.com/pwalczyszyn/MAX-2010-Projects/tree/master/UsersAdmin-robotlegs">
https://github.com/pwalczyszyn/MAX-2010-Projects/tree/master/UsersA...</a>).
Unfortunately his example didn’t use any popup windows.</p>
<p>There is Knowledge Base post on challenges of mediating a flex
popup but it only applies if using mediators so it would not apply
in my presentation model design where presentation model has no
knowledge of the view (<a href=
"http://knowledge.robotlegs.org/kb/reference-mvcs-implementation/how-to-mediate-a-flex-popup">http://knowledge.robotlegs.org/kb/reference-mvcs-implementation/how...</a>).</p></div>solzytag:robotlegs.tenderapp.com,2009-10-18:Comment/158452912012-05-08T12:57:15Z2012-05-08T12:57:15ZPresentation Model Pattern with Robotlegs and Popup Windows<div><p>Hello Solzy,</p>
<blockquote>
<p>Is this because Flex creates the popup outside of the context
view’s display list?</p>
</blockquote>
<p>Yes, that is exactly the problem. Unfortunately there is no
built-in solution for RL 1.x. There is a convenient work-around
though: using the SystemManager as your context view. Something
along the lines of:</p>
<pre>
<code><local:TestContext contextView="{ Application.application.systemManager }"/></code>
</pre>
<p>Hope that helps.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/158452912012-05-08T15:22:51Z2012-05-08T15:22:51ZPresentation Model Pattern with Robotlegs and Popup Windows<div><p>Thanks for the quick response. A follow on...</p>
<p>Is the SystemManager then the same context as that used by
Robotlegs? If yes, great. But even so, it only solves half my
problem. I still need to inject the presentation model class into
the view and in this case, the view is only created when I call
PopUpManager.createPopUp( ). And this doesn't result in an
injection. So is it true that injection will NOT happen for views
created this way (or even by calling a view's constructor) even
though I've defined needed injections in my Context class? Any
other thoughts on how to get my presentation models injected? Can I
manually inject the presentation model in some way?</p></div>solzytag:robotlegs.tenderapp.com,2009-10-18:Comment/158452912012-05-08T15:31:03Z2012-05-08T15:31:03ZPresentation Model Pattern with Robotlegs and Popup Windows<div><p>Hi. By using the SystemManager as your contextView, Robotlegs
should be able to catch any views that land on stage - even those
created in PopUps. You need to use the ViewMap to let Robotlegs
know which views to inject into. This technique should work for
your use-case, please let me know if you have any problems with
it.</p></div>Shaun Smith