MarcGiffing / wicket-spring-boot

Spring Boot starter for Apache Wicket
151 stars 61 forks source link

allows wicket filter to handle 404 errors #111

Closed mruckli closed 7 years ago

mruckli commented 7 years ago

In one of our projects we wanted to customize all the error pages. The documentation states that this is possible with the follwing three annotations:

@WicketExpiredPage
@WicketAccessDeniedPage
@WicketInternalErrorPage

The problem we faced is that requests which resulted in a 404 did not pass trough the wicket filter. In this pull request we configure the wicket filter to handle all requests. With this in place our error page gets correctly called.

I could also imagine to make this configurable to only handle REQUEST and ERROR and not all DispatcherTypes but in our case we just added all.

An other workaround we found is to just use the following snippeet in the init() method of our WicketBootSecuredWebApplication:

getWicketFilter().getFilterConfig().getServletContext().getFilterRegistration(WicketWebInitializer.WICKET_FILTERNAME).addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, props.getFilterMappingParam());

But this just adds an other mapping which is not exactly the proper way and prone to create issues if it gets added at the wrong place. FYI: we used it in version 1.x and not 2.x

MarcGiffing commented 7 years ago

I could also imagine to make this configurable to only handle REQUEST and ERROR and not all DispatcherTypes but in our case we just added all.

https://github.com/MarcGiffing/wicket-spring-boot/commit/f6141b9207c69d3ab0389af28b58a054358719bd like that?

mruckli commented 7 years ago

Exactly 👍 Thank you very much!