multiple view state
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?
Thanks,
Bharathi
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
Support Staff 1 Posted by Ondina D.F. on Jan 23, 2014 @ 03:35 PM
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: https://github.com/piercer/robotlegs-extensions-ViewInterfaceMediat...
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.
Ondina
2 Posted by bharathi.mohanr... on Jan 24, 2014 @ 02:26 AM
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.
Thanks,
Bharathi
bharathi.mohanraju closed this discussion on Jan 24, 2014 @ 02:34 AM.