Wicket 1.5.4 - Shiro LogoutPage.html does not have redirect component added error - with fix #99

Open
jamiemaher opened this Issue Mar 2, 2012 · 0 comments

1 participant

@jamiemaher

Hello,

Using Wicket 1.5.4 and wicketstuff-shiro 1.5.4 and I'm getting a error:

I'm mounting the logout page in my Wicket application:
mountPage("account/logout",org.wicketstuff.shiro.page.LogoutPage.class);

The error is:
"Unable to find component with id 'redirect' in [HtmlHeaderContainer [Component id = _header_0]]"

The source for the logout page contains the meta redirect wicket id, which never seems to be added in the
default PageParameters constructor.

The code contains the following which keeps processing the page (and expects all components to be added):
setResponsePage(pageClass);

So I modified the constructor slightly to throw a RestartResponseException instead which works in Wicket 1.5.4:

public LogOutPage(final PageParameters parameters)
    {
        final StringValue page = parameters.get(REDIRECTPAGE_PARAM);
        Class pageClass;
        if (!page.isNull())
            try
            {
                pageClass = (Class)Class.forName(page.toString());
            }
            catch (final ClassNotFoundException e)
            {
                throw new RuntimeException(e);
            }
        else
            pageClass = getApplication().getHomePage();


        setStatelessHint(true);
        
        // this should remove the cookie...
        final Subject subject = SecurityUtils.getSubject();
        LOG.info("logout: " + subject);
        subject.logout();
        Session.get().invalidateNow(); // invalidate the wicket session
        
        
        //redirect to correct page and stop processing this one.
        throw new RestartResponseException(pageClass);          
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment