You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Hendy Irawan (JIRA)" <ji...@apache.org> on 2014/08/05 05:44:11 UTC

[jira] [Created] (WICKET-5661) IRequestHandler implementation for RestartResponseAtInterceptPageException

Hendy Irawan created WICKET-5661:
------------------------------------

             Summary: IRequestHandler implementation for RestartResponseAtInterceptPageException
                 Key: WICKET-5661
                 URL: https://issues.apache.org/jira/browse/WICKET-5661
             Project: Wicket
          Issue Type: Improvement
          Components: wicket
    Affects Versions: 6.16.0
            Reporter: Hendy Irawan
            Priority: Minor


I'd like to throw e.g. {{NotLoggedInException}} which will be handled by {{onException}} which then does a {{RestartResponseAtInterceptPage}}:

{code}
private final class NotLoggedInRequestCycleListener extends AbstractRequestCycleListener {
	@Override
	public IRequestHandler onException(RequestCycle cycle, Exception ex) {
		// Since our actual exception is wrapped, we need to find based on the chain
		final List<Throwable> chain = Throwables.getCausalChain(ex);
		final NotLoggedInException notLoggedInException = Iterables.getFirst(
				Iterables.filter(chain, NotLoggedInException.class), null);
		if (notLoggedInException != null) {
			final Url url = cycle.getRequest().getClientUrl();
			log.debug("Got exception " + notLoggedInException.getClass().getName() + " on " + url, ex);
			final SoluvasWebSession session = (SoluvasWebSession) Session.get();
			session.setOriginalUrl(url);
			session.info("Please log in");
			session.dirty();
			throw new RestartResponseAtInterceptPageException(DedicatedLoginPage.class);
		} else {
			return super.onException(cycle, ex);
		}
	}
}
{code}

which doesn't work:

{code}
Caused by: javax.servlet.ServletException: Cannot process filter: org.apache.wicket.RestartResponseAtInterceptPageException
	at org.soluvas.web.site.SecuredWicketAtmosphereHandler$CustomFilterChain.doFilter(SecuredWicketAtmosphereHandler.java:201)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
	at org.soluvas.web.site.SecuredWicketAtmosphereHandler$CustomFilterChain.doFilter(SecuredWicketAtmosphereHandler.java:199)
	... 25 more
Caused by: org.apache.wicket.RestartResponseAtInterceptPageException
{code}

because Wicket requires an {{IRequestHandler}} instead in this phase.



--
This message was sent by Atlassian JIRA
(v6.2#6252)