简体   繁体   中英

Wicket 6 webapp context resources

Im migrating a wicket 1.4 application which has alot of js,css en images under the webapp context directory :

src/main/webapp
+js
++plugin1.js
++plugin2.js
+app
+css

etc

In our application we have used JavaScript.getHeaderContribution("js/plugin1.js");

The new wicket 6 implementation doesn't have this header contribution method.In stead you should use :

JavaHeaderItem.forReference(new JavaScriptResourceReference(Application.class,"js/plugin1.js");

But i dont want to use a scope! it will now search for files in the same package as the Application class. ContextRelativeReference is not valid in this location because it does not extend ResourceReference.

Any ideas about how i should access my webapp files without having to add every single file as a shared resource and reference it in my header contributor?

I have found the solution. It was easier then i expected.

You can simply use JavaScriptHeaderItem.forUrl("js/plugin1.js");

No reference and thus no scope needed.

Regards Niels

And what about mounted resource caching ?? Because when using this method nothing will be cached by browser!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM