Presentation Model Pattern with Robotlegs and Popup Windows

solzy's Avatar

solzy

08 May, 2012 10:33 AM

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.

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 https://github.com/pwalczyszyn/MAX-2010-Projects/tree/master/UsersA...). Unfortunately his example didn’t use any popup windows.

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 (http://knowledge.robotlegs.org/kb/reference-mvcs-implementation/how...).

  1. Support Staff 1 Posted by Shaun Smith on 08 May, 2012 12:57 PM

    Shaun Smith's Avatar

    Hello Solzy,

    Is this because Flex creates the popup outside of the context view’s display list?

    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:

    <local:TestContext contextView="{ Application.application.systemManager }"/>
    

    Hope that helps.

  2. 2 Posted by solzy on 08 May, 2012 03:22 PM

    solzy's Avatar

    Thanks for the quick response. A follow on...

    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?

  3. Support Staff 3 Posted by Shaun Smith on 08 May, 2012 03:31 PM

    Shaun Smith's Avatar

    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.

  4. Ondina D.F. closed this discussion on 29 Jun, 2012 09:25 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac