wicketstuff/core — Issue #99: Wicket 1.5.4 - Shiro LogoutPage.html does not have redirect component added error - with fix
Author: jamiemaher
Created: 2012-03-02 20:21:23+00:00
State: open

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