multiple view usage

tracstarr's Avatar


01 Apr, 2011 12:01 PM

I've currently got a view defined which has two additional view components, all three have mediators. The question is how do I set up injection and mediators to allow using multiple instances of the view? For example, what i'm trying to have is a tabbed interface, each tab contains the view (with it's sub view components), and each of these tabs is a unique instance with it's own data model attached.

So far I've created multiple model maps using:

injector.mapValue(LangModel, instance, name)

The name is dynamic and depends on the file a user opens. I've done this within a command for loading a file.
From here i'm stuck. I can't figure out how to link the named model to named views/mediators and then access those.

  1. 1 Posted by mike.cann on 02 Apr, 2011 08:58 AM

    mike.cann's Avatar

    Hi Tractarr,

    Im not entirely sure I follow you here. Perhaps a diagram or something may assist with explaining what you are trying to say.

    "The question is how do I set up injection and mediators to allow using multiple instances of the view?"

    All you need to do is in your context map a mediator class to a view class then every time an instance of that view is created a mediator will be too:


    Was this what you meant?


  2. 2 Posted by erik on 06 Apr, 2011 12:15 PM

    erik's Avatar

    Why don't you create 1 instance of LangModel and let it manage all your loaded documents? Like this:


    So let LangModel store a Data Transfer Object (also known as VO: for each of your loaded file. That way, your mediator can simply get the LangModel injected:

    public var languageModel : LangModel;

    And tell languageModel to give you the data you need:

  3. Stray closed this discussion on 11 May, 2011 08:44 AM.

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

Keyboard shortcuts


? 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