@Override
public Url mapHandler(IRequestHandler requestHandler)
{
if (requestHandler instanceof ResourceReferenceRequestHandler)
{
ResourceReferenceRequestHandler referenceRequestHandler = (ResourceReferenceRequestHandler)requestHandler;
ResourceReference reference = referenceRequestHandler.getResourceReference();
Url url;
if (reference instanceof ResourceBundleReference)
{
// unwrap the bundle to render the url for the actual reference
reference = ((ResourceBundleReference)reference).getBundleReference();
}
if (reference instanceof MetaInfStaticResourceReference)
{
url = ((MetaInfStaticResourceReference)reference).mapHandler(referenceRequestHandler);
// if running on Servlet 3.0 engine url is not null
if (url != null)
{
return url;
}
// otherwise it has to be served by the standard wicket way
}
else if (reference instanceof UrlResourceReference)
{
UrlResourceReference urlReference = (UrlResourceReference)reference;
url = urlReference.getUrl();
return url;
}
if (reference.canBeRegistered())
{
ResourceReferenceRegistry resourceReferenceRegistry = getContext().getResourceReferenceRegistry();
resourceReferenceRegistry.registerResourceReference(reference);
}
url = new Url();
List<String> segments = url.getSegments();
segments.add(getContext().getNamespace());
segments.add(getContext().getResourceIdentifier());
segments.add(getClassName(reference.getScope()));
// setup resource parameters
PageParameters parameters = referenceRequestHandler.getPageParameters();
if (parameters == null)
{
parameters = new PageParameters();
}