Wicket 会话超时后 - pageParameters 为空 [英] After Wicket session timeout - pageParameters are null

查看:71
本文介绍了Wicket 会话超时后 - pageParameters 为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 wicket 6.

I'm using wicket 6.

我的应用程序基于在构造函数中使用 pageParameters 创建的网页.我还使用了一个 pageParameter country,它是一个路径参数,定义为:

My application is based on WebPages created with pageParameters in the constructor. I'm using also a pageParameter country that is a path-parameter defined with:

mountPage("/${country}/pagepath", MyPage.class);

我在每一页都有很多有状态的表单.我现在正在尝试处理会话过期的情况(为了重现这种情况,我删除或修改了 jsessionid cookie).之后,我单击页面中的提交按钮,我希望 wicket 了解会话已过期.但我的行为是这样的:

I have many statefull forms in every page. I'm now trying to handle the case when the session expires (to reproduce this scenario I delete or modify the jsessionid cookie). After that I click a submit button in a page and I'd expect wicket to understand that the session has expired. But the behaviour that I have is this:

  • 重新加载当前页面,但页面参数为空"
  • 使用如下包符号重写 url:

  • the current page is reloaded but the pageparameters are 'null'
  • the url is rewritten using the package notation like:

localhost:8080/wicket/bookmarkable/com.test.pages.MyPage

所以看起来 url 映射不知何故丢失了.

So it looks like the url mapping is somehow lost.

我需要使用 pageParameters 信息重新加载同一页面,或者显示一个信息页面,上面写着类似单击此处重新加载的内容.

I need to reload the same page with pageParameters information or show an info page that says something like click here to reload.

我已经尝试使用:

getApplicationSettings().setPageExpiredErrorPage(HomePage.class); 

但这没有帮助.

感谢任何帮助.谢谢.

推荐答案

看起来 Wicket 6 中存在导致此问题的错误:https://issues.apache.org/jira/browse/WICKET-5068

Looks like there is a bug in Wicket 6 which causes this issue: https://issues.apache.org/jira/browse/WICKET-5068

它在 Wicket 7 中得到修复.对于 Wicket 6,有一个解决方法:禁用 WICKET-4594 修复.

It is fixed in Wicket 7. For Wicket 6, there is a workaround: disable WICKET-4594 fix.

首先添加以下映射器:

public class BookmarkableMapperThatSavesPageParametersForListener extends BookmarkableMapper {
    @Override
    protected PageParameters getPageParametersForListener(PageInfo pageInfo, PageParameters pageParameters) {
        return pageParameters;
    }
}

然后使用它来替换 Application#init() 中的内置 BookmarkableMapper(必须在使用根映射器进行任何操作之前添加):

Then use it to replace a built-in BookmarkableMapper in your Application#init() (this has to be added before any manipulations with the root mapper):

mount(new BookmarkableMapperThatSavesPageParametersForListener());

这种方法在我们的应用程序中有效,它似乎没有破坏任何东西.

This approach works in our application and it does not seem to break anything.

更多信息:Wicket 6:空 PageParameters when过期后重新创建页面

这篇关于Wicket 会话超时后 - pageParameters 为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆