当GWT中的Cookie刚刚过期时,如何触发事件?
好的,这是要求 我想构建一个如下所示的系统: - Header: have a PleaseLoginPanel and SuccessfulLoginPanel - Content Page just contains content & communicate with header via EventBuss - HeaderPresenter is the parent presenter & ContentPresenter is nested inside the Header presenter. -标题:有一个PleaseLoginPanel和SuccessfulLoginPanel -内容页只包含内容&通过事件总线与标题通信 -HeaderPresenter是父presenter&ContentPresenter嵌套在Header presenter中。 假设当用户打开此url“当GWT中的Cookie刚刚过期时,如何触发事件?,gwt,gwtp,Gwt,Gwtp,好的,这是要求 我想构建一个如下所示的系统: - Header: have a PleaseLoginPanel and SuccessfulLoginPanel - Content Page just contains content & communicate with header via EventBuss - HeaderPresenter is the parent presenter & ContentPresenter is nested inside the Header pr
mydomain\content
”时,他们将看到一个页面,其顶部包含标题PleaseLoginPanel
,以及一个内容部分(标题下方),其中包含一些textarea
和按钮,供用户输入数据并提交给数据库
为了能够访问内容页中的小部件,用户需要登录,登录后,PleaseLoginPanel
将不可见,并且SuccessfulLoginPanel
将可见。用户现在可以在内容部分使用小部件
假设会话和Cookies
将持续1小时,会话Cookies过期后,用户无法提交内容数据
假设用户花费了大量精力准备数据&即将提交,但会话已过期,无法提交。此时,标题中的SuccessfulLoginPanel
仍保留在那里。因此,用户可能会丢失以前准备的所有内容。您可能会说,他可以打开一个新页面&登录并复制旧页面(会话已过期且没有PleaseLoginPanel
)中的数据,但这仍然需要他花费大量精力进行复制
所以我想知道,当Cookes刚刚过期时,它将向标题触发一个事件&要求标题显示PleaseLoginPanel
我们如何在GWT或GWTP中做到这一点?找到了一个解决方案,即使用定时器
Timer showLoginPanelTimer = new Timer() {
public void run() {
getView().getLoginPanel().setVisible(true);
getView().getSuccessfulLoginPanel().setVisible(false);
getView().getEmailBox().setText("");
getView().getPasswordBox().setText("");
Utility.removeUserInfoCookies();
}
};
showLoginPanelTimer.schedule(Utility.COOKIE_TIMEOUT);