multiple view state

bharathi.mohanraju's Avatar


23 Jan, 2014 03:28 AM

Dear Support,

I am using RL1
My problem definition is something like this. Consider a ProductManagement application.
- It has a ProductsList - on selection of a product, ProductDetails can be viewed and modified - The ProductDetails view state is maintained in ProductModel - Until now i cud view the details of only one product at a time

Now i have a requirement to view/update multiple products. So i should be able to open multiple ProductDetails windows and each should have its own view state maintained using ProductModel

How can i achieve this?


  1. Support Staff 1 Posted by Ondina D.F. on 23 Jan, 2014 03:35 PM

    Ondina D.F.'s Avatar

    Hello Bharathi,

    You marked your post as private. Should we keep it this way, or have you marked it as such by accident?

    Create a ProductsListView and a ProductDetailsContainer. ProductDetailsContainer will hold 1 or more ProductDetailsView(s).
    I recommend creating an interface for ProductDetailsView, say IProductDetailsView, and then mapping IProductDetailsView to ProductDetailsMediator. In robotlegs version 1 that is only possible if you use this utility:

    The mapping would look like this:
    mediatorMap.mapView(IProductDetailsView, ProductDetailsMediator);

    In robotlegs version 2 this functionality is provided by the framework.

    Anyway, after you mapped the view, you can inject the interface into your ProductDetailsMediator:

    [Inject] public var view: IProductDetailsView;

    Now, the ProductDetailsContainer should be mediated, so when the user chooses an item from the ProductsListView, ProductsListMediator dispatches an event with the selected item or an id (the VO's id in your list) as a payload. You could as well dispatch an event, with the id or a VO as a payload, from the Model, when you set the selected item on the Model.

    ProductDetailsContainerMediator listens for that event and tells its view (ProductDetailsContainer) to add a ProductDetailsView to the stage and to set a property, say _viewId to the value of the event's payload, which is the id of the selected item in the list. You could also pass the entire VO (the details of the selected product) transported by the event's payload on to ProductDetailsView, or as shown bellow.

    The moment ProductDetailsView is added to the stage, a ProductDetailsMediator will be created.
    In its onRegister() you can ask the Model ( via an event-> command->model or however you usually do) for the currently selected item in your ProductsListView, based on the _viewId. When data returns, you populate that view with the details. The _viewId can help you differentiate between multiple mediators, for instance when you have to listen for an event dispatched from somewhere else in your application, and you want just a certain mediator to react to it.


  2. 2 Posted by bharathi.mohanr... on 24 Jan, 2014 02:26 AM

    bharathi.mohanraju's Avatar

    Dear Ondina,

    Thank you very much for the guidelines.

    I was not maintaining the ProductList in ProductModel. May be i should now.

    This thread can be closed.


  3. bharathi.mohanraju closed this discussion on 24 Jan, 2014 02:34 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