Refresh entire wicket page

I am working on a project when a user session will be replaced by clicking on the link. Since all the data in the header, footer and content (i.e., on the whole page) depends on the session data, it is necessary to reload the entire page (all subpages). I tried bookmarkablepagelink, but I can not perform the action (change session) on this link. I also tried to create a link that will change the session, and then programmatically click on the bookmarkablepagelink link, but I cannot find a way to click the link without using javascript (and this is not an alternative in this project).

Any good suggestions on how to do this?

+4
source share
2 answers

In the onClick method for the link, perform a reset session and then

 setResponsePage(getPage()); 

and the page should be updated well.

+5
source

The solution to your problem is twofold: you are replacing the session, probably best done through

 getSession().invalidateNow(); 

and sends a redirect to the bookmark url. This can also be done with setResponsePage :

 setResponsePage(OtherPage.class, new PageParameters().add("foo", "bar")); 

This will send a 302 redirect to the browser with the bookmark URL and provide parameters, which will give the servlet container the ability to reset the session (basically log out), waiting for the browser to respond. It also initiates a new session cookie (since the previous session is no longer active).

+5
source

Source: https://habr.com/ru/post/1438380/


All Articles