Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alter URL prefix for Wicket resource URLs?

Wicket automatically generates URLs to resources (images etc.) with the prefix "resources" (e.g. "http://localhost:8080/resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js"). Is it possible to change this prefix from "resources" to something else (like "res")?

I have another servlet providing stuff under "resources" and I cannot change it (don't ask...), hence I would like Wicket to serve its resources with a different prefix.

Thanks!

like image 289
tbk Avatar asked Oct 25 '22 08:10

tbk


1 Answers

This is not possible in Wicket 1.4, since the path is defined as the constant org.apache.wicket.protocol.http.request.WebRequestCodingStrategy.RESOURCES_PATH_PREFIX and is used hardcoded in the Wicket filter.

In Wicket 1.5 it seems you have to override org.apache.wicket.Application.getEncoderContext() with an IMapperContext which returns your new prefix in getResourceIdentifier().

like image 52
Heri Avatar answered Nov 11 '22 08:11

Heri