wicket

Apache Wicket 9.7.0 resource bundle naming issue


I'm aggregating JavaScript resources like this

getResourceBundles().addJavaScriptBundle(MyWicketApplication.class,
                "js_bundle.js",
                wicketJQuery,
                wicketAjax,
                JavascriptResources.RESOURCE_1.getReference(),
                JavascriptResources.RESOURCE_2.getReference(),
                JavascriptResources.RESOURCE_3.getReference(),
                JavascriptResources.RESOURCE_4.getReference(),
                JavascriptResources.RESOURCE_5.getReference(),
                JavascriptResources.RESOURCE_6.getReference(),
                JavascriptResources.RESOURCE_7.getReference(),
                JavascriptResources.RESOURCE_8.getReference());

What I get after a page is rendered is something like this

./wicket/resource/com.my.company.MyWicketApplication/js_bundle-ver-3CA0BF236223C36D08331F94E24FAAAE.js

I don't mind having the part

js_bundle-ver-3CA0BF236223C36D08331F94E24FAAAE.js

But how to hide / remove this part

./wicket/resource/com.my.company.MyWicketApplication

to something like this

/resources/js_bundle-ver-3CA0BF236223C36D08331F94E24FAAAE.js

Solution

  • You could use the result of getResourceBundles().addJavaScriptBundle(...) and mount it at specific path:

     JavaScriptReferenceHeaderItem jsrhi = getResourceBundles().addJavaScriptBundle(...);
     ResourceReference rr = jsrhi.getReference();
     webApplication.mountResource("some/path", rr);