Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/npm/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当GWT中的Cookie刚刚过期时,如何触发事件?_Gwt_Gwtp - Fatal编程技术网

当GWT中的Cookie刚刚过期时,如何触发事件?

当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

好的,这是要求

我想构建一个如下所示的系统:

- 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“
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);