Awesome
wicket-webjars
Integration of webjars for Apache Wicket.
wicket-webjars dependes on webjars.
Current release version:
- For Wicket 8.x use 2.x
- For Wicket 7.x use 0.5.x
- For Wicket 6.x use 0.4.x
Documentation:
Add maven dependency:
<dependency>
<groupId>de.agilecoders.wicket.webjars</groupId>
<artifactId>wicket-webjars</artifactId>
<version>0.4.10</version>
</dependency>
Installation:
/**
* @see org.apache.wicket.Application#init()
*/
@Override
public void init() {
super.init();
// install 3 default collector instances
// (FileAssetPathCollector(WEBJARS_PATH_PREFIX), JarAssetPathCollector, VfsAssetPathCollector)
// and a webjars resource finder.
WebjarsSettings settings = new WebjarsSettings();
WicketWebjars.install(this, settings);
}
Usage
Add a webjars resource reference (css,js) to your IHeaderResponse:
public WebjarsComponent extends Panel {
public WebjarsComponent(String id) {
super(id);
}
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(JavaScriptHeaderItem.forReference(new WebjarsJavaScriptResourceReference("jquery/1.8.3/jquery.js")));
}
}
Add dependencies to your pom.xml:
<dependencies>
<dependency>
<groupId>de.agilecoders.wicket.webjars</groupId>
<artifactId>wicket-webjars</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>1.8.3</version>
</dependency>
</dependencies>
It is also possible to use a resource by adding it to your html markup directly:
<img src="/webjars/jquery-ui/1.9.2/css/smoothness/images/ui-icons_cd0a0a_256x240.png"/>
Note: The above works only for Servlet 3 web containers! Embedded Jetty needs extra configuration to enable this feature!
To use always recent version from your pom you have to replace the version in path with the string "current". When resource name gets resolved this string will be replaced by recent available version in classpath. (this feature is available since 0.2.0)
public WebjarsComponent extends Panel {
public WebjarsComponent(String id) {
super(id);
}
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(JavaScriptHeaderItem.forReference(new WebjarsJavaScriptResourceReference("jquery/current/jquery.js")));
}
}