I implement a custom JSF component with a JS and CSS file, and provide this component in a JAR, is it possible to inject the CSS and JS file or reference into the html that use my component by this component itself? And the Jar structure is like
- src
aComponent.java
-resources
-js
acomponent.js
-css
acompponent.css
I try to implement in encodeBegin() and encodeEnd() in acomponent.java like
public void encodeBegin(FacesContext context) {
VirtualResource.addJsResource(context, getClass().getPackage().getName().replace('.', '/') + "/js/acomponent.js");
}
But it does not work, does anyone knows how I can do this?
When any one use my jar and the acomponent in his html, it will load the CSS and JS by the component itself