tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/13-removeadd-viewRobotlegs: Discussion 2013-04-28T10:03:26Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T10:33:59Z2009-11-25T10:34:02ZRemove/Add View?<div><p>Hi there,<br>
what is the best way to remove a view/mediator and change to the
next view/mediator (i am not using flex)?</p>
<p>// does robotlegs offers any utils?</p></div>Fabiantag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T10:36:03Z2009-11-25T10:36:03ZRemove/Add View?<div><p>Hi Fabian,</p>
<p>could you explain a bit more what it is you're trying to
accomplish?<br>
Views and their mediators can be added/ removed in many ways so
it<br>
would be helpful to know a bit more.</p>
<p>thanks,<br>
till</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T10:48:15Z2009-11-25T10:48:19ZRemove/Add View?<div><p>Ok, it's a realysimple "twitter-reader" (Reading Tweets by
Username).</p>
<p>In my first view, the user can enter the username.<br>
In my second view, i show a list of tweets and a back-button (to
first view).</p>
<p>I'am not sure how to change between these to views. They must be
added/removed somehow by someone.</p>
<p>g.</p></div>Fabiantag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T10:54:17Z2009-11-25T10:54:17ZRemove/Add View?<div><p>For such a small app, I'd recommend keeping both views around
and just<br>
hiding the inactive one. Use a model to store view state, i.e.
which<br>
view should be active. Let the model dispatch some sort of id for
the<br>
view that should be visible and hide the other one in the
mediators<br>
listener for that event.<br>
Another option would be to register the mediators with the model
and<br>
let the model keep track of which view is active. That way, you
could<br>
grow the number of views without having lots of duplicated activity
in<br>
the mediators on each view change.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T13:47:45Z2009-11-25T13:47:51ZRemove/Add View?<div><p>Ok.</p>
<p>My ListView fires:<br>
dispatchEvent(new Event(TweetListView.BACK, true));</p>
<p>The ListViewMediator listens:<br>
eventMap.mapListener(tweetListView, TweetListView.BACK,
handleBackButton);<br>
and relays the event to the framework<br>
function handleBackButton(event : Event) : void { dispatch(event);
}</p>
<p>My SeachViewMedator listens.<br>
eventMap.mapListener(eventDispatcher, TweetListView.BACK,
handleBackButton);<br>
BUT: I dont get any events here ;-(</p>
<p>Whats wrong?<br></p></div>Fabiantag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T13:57:31Z2009-11-25T13:57:31ZRemove/Add View?<div><p>Looks like it should be working. Have you verified that the<br>
dispatch(event) happens, i.e. that handleBackButton gets
called?</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T14:42:35Z2009-11-25T14:42:48ZRemove/Add View?<div><p>The Events gets fired.<br>
But only one of the two mediators recieves it.</p>
<p>Same with a Framework event of my TwitterService. MediatorA gets
the events, MediatorB (the bad one) not.<br></p></div>Fabiantag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T14:48:54Z2009-11-25T14:48:54ZRemove/Add View?<div><p>That's really weird.</p>
<p>Can you maybe attach the mediator class that's not working
(and,<br>
ideally, also the working one). You can strip out the
proprietary<br>
pieces, of course.</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T14:51:50Z2009-11-25T14:52:02ZRemove/Add View?<div><p>damn, i missed a removeMediator() – sry.<br>
Now everythings works fine.</p></div>Fabiantag:robotlegs.tenderapp.com,2009-10-18:Comment/6342192009-11-25T14:54:22Z2009-11-25T14:54:22ZRemove/Add View?<div><p>Cool, glad it worked out!</p></div>Till Schneidereit