Remove/Add View?
Hi there,
what is the best way to remove a view/mediator and change to the
next view/mediator (i am not using flex)?
// does robotlegs offers any utils?
Comments are currently closed for this discussion. You can start a new one.
Hi there,
what is the best way to remove a view/mediator and change to the
next view/mediator (i am not using flex)?
// does robotlegs offers any utils?
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Till Schneidereit on 25 Nov, 2009 10:36 AM
Hi Fabian,
could you explain a bit more what it is you're trying to accomplish?
Views and their mediators can be added/ removed in many ways so it
would be helpful to know a bit more.
thanks,
till
3 Posted by Fabian on 25 Nov, 2009 10:48 AM
Ok, it's a realysimple "twitter-reader" (Reading Tweets by Username).
In my first view, the user can enter the username.
In my second view, i show a list of tweets and a back-button (to first view).
I'am not sure how to change between these to views. They must be added/removed somehow by someone.
g.
Support Staff 4 Posted by Till Schneidereit on 25 Nov, 2009 10:54 AM
For such a small app, I'd recommend keeping both views around and just
hiding the inactive one. Use a model to store view state, i.e. which
view should be active. Let the model dispatch some sort of id for the
view that should be visible and hide the other one in the mediators
listener for that event.
Another option would be to register the mediators with the model and
let the model keep track of which view is active. That way, you could
grow the number of views without having lots of duplicated activity in
the mediators on each view change.
5 Posted by Fabian on 25 Nov, 2009 01:47 PM
Ok.
My ListView fires:
dispatchEvent(new Event(TweetListView.BACK, true));
The ListViewMediator listens:
eventMap.mapListener(tweetListView, TweetListView.BACK, handleBackButton);
and relays the event to the framework
function handleBackButton(event : Event) : void { dispatch(event); }
My SeachViewMedator listens.
eventMap.mapListener(eventDispatcher, TweetListView.BACK, handleBackButton);
BUT: I dont get any events here ;-(
Whats wrong?
Support Staff 6 Posted by Till Schneidereit on 25 Nov, 2009 01:57 PM
Looks like it should be working. Have you verified that the
dispatch(event) happens, i.e. that handleBackButton gets called?
7 Posted by Fabian on 25 Nov, 2009 02:42 PM
The Events gets fired.
But only one of the two mediators recieves it.
Same with a Framework event of my TwitterService. MediatorA gets the events, MediatorB (the bad one) not.
Support Staff 8 Posted by Till Schneidereit on 25 Nov, 2009 02:48 PM
That's really weird.
Can you maybe attach the mediator class that's not working (and,
ideally, also the working one). You can strip out the proprietary
pieces, of course.
9 Posted by Fabian on 25 Nov, 2009 02:51 PM
damn, i missed a removeMediator() – sry.
Now everythings works fine.
Support Staff 10 Posted by Till Schneidereit on 25 Nov, 2009 02:54 PM
Cool, glad it worked out!