user1728451
user1728451

Reputation: 41

Refresh entire page wicket

I'm working on a project where the user session is going to be replaced when clicking on a link. Since all the data in the headerpage, footer and content (i.e. the entire page) depends on the session data, the entire page (all subpages) has to be reloaded. I've tried bookmarkablepagelink, but i can not put an action (changing the session) on this link. I've also tried to make a link that changes the session and afterwards click the bookmarkablepagelink programmatically, but i can't find a way to click the link without using javascript (and that is no alternative in this project).

Any good suggestions how to do this?

Upvotes: 4

Views: 16099

Answers (2)

Martijn Dashorst
Martijn Dashorst

Reputation: 3692

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

getSession().invalidateNow();

and sending a redirect to a bookmarkable URL. This can be done with setResponsePage as well:

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

This will send a 302 redirect to the browser with the bookmarkable URL and provided parameters, giving the servlet container ample opportunity to reset the session (basically logout the user) while waiting for the browser to respond. It will also trigger a new session cookie (as the previous session is no longer active).

Upvotes: 5

Don Roby
Don Roby

Reputation: 41137

In the onClick method for the link, do the session reset and then

setResponsePage(getPage());

and the page should refresh nicely.

Upvotes: 5

Related Questions