What happens when placeManager.revealCurrentPlace() is called

60 views
Skip to first unread message

mash dev

unread,
Nov 11, 2015, 4:19:11 PM11/11/15
to GWTP
Hi everyone,

I got a question regarding revealing a place.

I thought, that revealing a place may do something like the following calls on the presenter that should be revealed:
presenter.onReveal()
presenter.onReset()

Now I got a presenter with a gwt datepicker, that has some transient styles on it. That means, after a redraw, these styles will disappear.


For some reason, the datepicker will be redrawn after calling placeManager.revealCurrentPlace(), but it wont when i call onReset().

My question is, how can I achieve the same behaviour (some sort of redraw) of revealCurrentPlace(), without  calling placeManager.revealCurrentPlace(). (The point is,I just cant use the revealCurrentPlace() method).
Or how can I achieve a redraw of my widget?

Thanks in advance.
Regards,
Manuel


Joel Trottier-Hebert

unread,
Nov 20, 2015, 9:43:12 AM11/20/15
to GWTP
Hi Mash,

to answer the first question "what happens when revealCurrentPlace() is triggered"

I've bug a bit in GWTP's code to find out that this method will handle history token changes by doing this:

try {
if (historyToken.trim().equals("")) {
unlock();
revealDefaultPlace();
} else {
placeHierarchy = tokenFormatter.toPlaceRequestHierarchy(historyToken);
doRevealPlace(getCurrentPlaceRequest(), true);
}
} catch (TokenFormatException e) {
unlock();
error(historyToken);
NavigationEvent.fire(this, null);
}


So basically: if the new history token is empty -- it reveals the default place or else, it will try to reveal the place that matches the new token. If there's an error any of that, it'll reveal the error place.

Now about your comment about onReset() vs revealCurrentPlace(), I have a simple question, what kind of widget is it? Is it a PresenterWidget or just a regular GWT Widget?

Let me post a picture from the docs, explaining GWTP's lifecycle. If your widget is a PresenterWidget, you might want to identify what happens with GWTP's lifecycle in your scenario

Diagram
so one of the reasons I think might explain why it works on revealCurrentPlace() but not onReset() is that revealCurrentPlace() triggers other steps of the lifecycle depending of if the presenter is bound and visible.

As for your last question, "how do I redraw X", that will depend on the type of widget itself (I'd need more details about your implementation). For example I know that GWT CellTable has an explicit redraw method. In other cases, I've seen some dirty hacks with ScheduleDeferred to redraw the Element.

I hope that this helps you. Don't hesistate posting some code so we can help you more. (Specifically the widget and the way you're adding your styles on it)

-- Joel
Reply all
Reply to author
Forward
0 new messages