GWT:我如何从Activity开始方法中去一个新的地方? [英] GWT: how do I go to a new place from within the Activity start method?
本文介绍了GWT:我如何从Activity开始方法中去一个新的地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class SecureActivity extends AbstractActivity {
public void start(AcceptsOneWidget container,EventBus eventBus){
if(!_app.isUserLoggedIn()){
_app.goTo(new LoginPlace(_app.getCurrentPlaceToken()))
} else {
//确实安全的东西
code
但是我看到的行为是我的浏览器的历史记录是针对原始网址(来自原始请求),然后是登录名:redirectPlace,然后是原始网址。
好像我需要在start()方法完成后执行重定向。有没有适当的方法来延迟/委托goTo发生在start方法之外?
谢谢。
解决方案这应该够了:
$ b Scheduler.get ().scheduleFinally(new ScheduledCommand(){
@Override
public void execute(){
_app.goTo(new LoginPlace(_app.getCurrentPlaceToken());
}
}
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.
It seems like I need to do my redirection after the start() method has completed. Is there a proper way to delay/delegate that goTo to happen outside of the start method?
Thanks.
解决方案 That should be enough:
Scheduler.get().scheduleFinally(new ScheduledCommand() {
@Override
public void execute() {
_app.goTo(new LoginPlace(_app.getCurrentPlaceToken());
}
}
这篇关于GWT:我如何从Activity开始方法中去一个新的地方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文