tag:robotlegs.tenderapp.com,2009-10-18:/discussions/questions/7939-multiple-view-stateRobotlegs: Discussion 2018-10-18T16:35:54Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/312627792014-01-23T15:35:56Z2014-01-23T15:35:56Zmultiple view state<div><p>Hello Bharathi,</p>
<p>You marked your post as private. Should we keep it this way, or
have you marked it as such by accident?</p>
<p>Create a ProductsListView and a ProductDetailsContainer.
ProductDetailsContainer will hold 1 or more
ProductDetailsView(s).<br>
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: <a href=
"https://github.com/piercer/robotlegs-extensions-ViewInterfaceMediatorMap">
https://github.com/piercer/robotlegs-extensions-ViewInterfaceMediat...</a></p>
<p>The mapping would look like this:<br>
mediatorMap.mapView(IProductDetailsView,
ProductDetailsMediator);</p>
<p>In robotlegs version 2 this functionality is provided by the
framework.</p>
<p>Anyway, after you mapped the view, you can inject the interface
into your ProductDetailsMediator:</p>
<p>[Inject] public var view: IProductDetailsView;</p>
<p>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.</p>
<p>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.</p>
<p>The moment ProductDetailsView is added to the stage, a
ProductDetailsMediator will be created.<br>
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.</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/312627792014-01-24T02:26:24Z2014-01-24T02:26:24Zmultiple view state<div><p>Dear Ondina,</p>
<p>Thank you very much for the guidelines.</p>
<p>I was not maintaining the ProductList in ProductModel. May be i
should now.</p>
<p>This thread can be closed.</p>
<p>Thanks,<br>
Bharathi</p></div>bharathi.mohanraju