cobaltduck
cobaltduck

Reputation: 1598

Wicket setResponsePage after a session timeout

This is the onSubmit() method of my Wicket 1.5 application's login page:

@Override
public void onSubmit() {
    super.onSubmit();
User theUser = loginForm.getModelObject();

/* call a DAO function to check the user's credentials */
if(/* DAO call succeeds*/) {
    MyCustomeSession authSession = (MyCustomSession)Session.get();
        authSession.success("Welcome, " + theUser.getFullName());
    setResponsePage(new HomePage());
}
else {
    loginForm.error("Username or password was incorrect");
}   
}

This works fine for initial login, and for logout then log back in, in that the next thing seen is the Home page with the Welcome message.

Upon session timeout, this application redirects the user back to this same login page, with a feedback message "Your session has expired blah, blah" and allows user to enter username and password again. If the user does this, the login is successful: menus that were hidden become visible, the Welcome message shows, etc.

However, the page shown remains the Login page, with additional feedback messages for the required username and password (even though both had been entered and the login succeeded). Here is a clipped screen shot:

after session timeout feedback panel

Is this some weird thing with Wicket? Is there a fix or a work-around?

Upvotes: 1

Views: 3509

Answers (1)

cobaltduck
cobaltduck

Reputation: 1598

Well, it seems that a page which is a application.setPageExpiredErrorPage(page) cannot subsequently do a setResponsePage(new HomePage()); but must instead do setRepsonsePage(HomePage.class);.

Meanwhile, when this LoginPage is just a normal page, i.e. on initial login or after a logout, it must use setResponsePage(new HomePage()); This doesn't make much sense, but that seems to be the Wicket way.

So I added a boolean value to the LoginPage constructor called isTimeout and call one or the other version of setResponsePage accordingly.

Upvotes: 4

Related Questions