With help of the Ajax4JSF filter you can serve resources that are in the classpath of your application or in jar file.
Basic usage
Serving resources with standard components
<h:graphicImage src="resources:///org/myapp/resources/images/button.jpg" />
Serving javascript files
You could serve javascript files using a4j:loadScript component. The loaded script will be included in the
Serving CSS files
You could serve css files using a4j:loadStyle component. The loaded css file will be included in the
Creating component that requires javascript/css
If your component need custom javascript/css file you can simply add HtmlLoadScript/HtmlLoadStyle component as child of your component.
Tips
If you have component that uses HtmlLoadScript/HtmlLoadStyle as a child you do not need to create the child every time the component is rendered. First time you create the component add the child component that loads resources and store a variable in the request scope and put a logic code not to add the childs if than request variable exists.
Comments