multiple view usage

tracstarr's Avatar

tracstarr

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:

    mediatorMap.mapView(MyView,MyMediator);
    

    Was this what you meant?

    Cheers,
    Mike

  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:

    injector.mapSingleton(LangModel);
    

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

    [Inject]
    public var languageModel : LangModel;
    

    And tell languageModel to give you the data you need:

    languageModel.getDataById("tab0");
    
  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

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