After Wicket session timeout - pageParameters are null

842 views Asked by At

I'm using wicket 6.

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

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:

  • 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
    

So it looks like the url mapping is somehow lost.

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

I've already tried to use:

getApplicationSettings().setPageExpiredErrorPage(HomePage.class); 

but that didn't help.

Any help is appreciated. Thanks.

2

There are 2 answers

0
user250343 On

You could ask your question in the wicket mailing list. What you are observing might be a bug. Please check PageParameters missing from re-created Page

Conceptually, it should be possible to submit the form normally even if you need an authenticated user session. If the session is expired then you may be able to re-create a user session with a remember-me cookie. Wicket should re-construct the page with parameters, apply the form values and process the submit. In case where the page is stateful, there could be some complications that are possibly resolvable. If you find that your use case is not supported with stateful pages then you could file an issue and meanwhile use StatelessForm.

0
Roman Puchkovskiy On

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

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

First add the following mapper:

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

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.

More info: Wicket 6: empty PageParameters when recreating a page after expiration