[英]GWT: how do I go to a new place from within the Activity start method?
So I'm doing something like this: 所以我做的是这样的:
public class SecureActivity extends AbstractActivity {
public void start(AcceptsOneWidget container, EventBus eventBus) {
if (!_app.isUserLoggedIn()) {
_app.goTo(new LoginPlace(_app.getCurrentPlaceToken()))
} else {
// do cool secure stuff
}
}
}
But the behavior that I'm seeing is that my browser's history is for original url (from the original request), then the login:redirectPlace, and then original url again. 但我看到的行为是我的浏览器的历史记录是原始网址(来自原始请求),然后是登录:redirectPlace,然后是原始网址。
It seems like I need to do my redirection after the start() method has completed. 看起来我需要在start()方法完成后进行重定向。 Is there a proper way to delay/delegate that goTo to happen outside of the start method?
是否有一种正确的方法来延迟/委托goTo在start方法之外发生?
Thanks. 谢谢。
That should be enough: 这应该足够了:
Scheduler.get().scheduleFinally(new ScheduledCommand() {
@Override
public void execute() {
_app.goTo(new LoginPlace(_app.getCurrentPlaceToken());
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.