}
});
}
private <W extends IsWidget> void pageHiding(final W widget, final Request<W> request, final boolean fireEvent) {
final NavigationControl control = new NavigationControl(new Runnable() {
@Override
public void run() {
final Access<W> accessEvent = new AccessImpl<W>();
accessEvent.fireAsync(widget, new LifecycleCallback() {
@Override
public void callback(final boolean success) {
if (success) {
locked = true;
try {
hideCurrentPage();
request.pageNode.pageShowing(widget, request.state);
// Fire IOC lifecycle event to indicate that the state of the
// bean has changed.
// TODO make this smarter and only fire state change event when
// fields actually changed.
stateChangeEvent.fireAsync(widget);
setCurrentPage(request.pageNode);
currentWidget = widget;
navigatingContainer.setWidget(widget);
request.pageNode.pageShown(widget, request.state);
} finally {
locked = false;
}
handleQueuedRequests(request, fireEvent);
}
else {
request.pageNode.destroy(widget);
}
}
});
}
});
if (currentPage != null && currentWidget != null && currentWidget.asWidget() == navigatingContainer.getWidget()) {
currentPage.pageHiding(currentWidget, control);
}
else {
control.proceed();
}
}