tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/9777-switching-between-viewseg-remove-one-and-replaceRobotlegs: Discussion 2014-02-13T09:44:25Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/315780732014-02-12T13:59:23Z2014-02-12T13:59:23ZSwitching between Views(e.g remove one and replace)<div><p>Hi, I got another Question.<br>
Suppose you have one view with a Button and when that Button is
clicked you want to remove that view from the Context View, get rid
of all Mediators for that view and now add Another completely
different view.</p>
<p>What I saw from those FlowCharts for RL2 I receive the Event in
the Mediator, dispatch it again, have a mapped Command react to
that and change the values in the Model, dispatching another event,
have the Mediator receive it and change the view appropriatly. So
now I wonder where would you get manipulate the View to add new
Components?</p>
<p>I would guess I could dispatch an Event in the Mediator listen
in another Mediator/Simple Class that has the contextView Injected
and have it remove the old Components and add the new ones. Would
that be recommended?</p>
<p>The scenario could be screen Switching in games etc.</p>
<p>Thanks again.</p></div>dhagenblntag:robotlegs.tenderapp.com,2009-10-18:Comment/315780732014-02-12T15:00:23Z2014-02-12T15:03:42ZSwitching between Views(e.g remove one and replace)<div><blockquote>
<p>I would guess I could dispatch an Event in the Mediator listen
in another Mediator/Simple Class that has the contextView Injected
and have it remove the old Components and add the new ones. Would
that be recommended?</p>
</blockquote>
<p>Yes.<br>
If, say, ParentView is the one containing FirstChildView,
FirstChildMediator would redispatch an event on behalf of its view,
when the FirstChildView's button is clicked. ParentMediator would
listen for that event and would let its view (ParentView) remove
the FirstChildView and add a SecondChildView.<br>
FirstChildMediator will be removed automatically when
FirstChildView leaves the stage (under normal conditions), and
SecondChildMediator will be created automatically when
SecondChildView is added to the stage.</p>
<p>If you meant clicking a button inside of ParentView in order to
switch between child-views, then PaentView removes FirstChildView
and adds SecondChildView, and it dispatches an event for
ParentMediator to re-dispatch it, in case there is a need for
updating a Model</p>
<p>As a general rule, mediated views should communicate with each
other via their Mediators.<br>
Adding and removing child views/components should happen in the
view.</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/315780732014-02-12T19:53:33Z2014-02-12T19:53:33ZSwitching between Views(e.g remove one and replace)<div><p>I appreciate your quick Answers. I have another unrelated
Question but I guess I will open a new Discussion so it is easier
to search for.</p>
<p>Thanks.</p></div>dhagenblntag:robotlegs.tenderapp.com,2009-10-18:Comment/315780732014-02-13T09:44:24Z2014-02-13T09:44:24ZSwitching between Views(e.g remove one and replace)<div><p>No problem!<br>
Yes, please start a new discussion for other questions. I'm going
to close this for now.</p></div>Ondina D.F.