I’d like to know if its possible, by using GWT, Struts2 of JSF, provide to the client the resources (such as .css file) only if a page need it in that moment.
I don’t mean include the CSS on the page loaded in that moment, but if exist a mechanism that manages this process automatically.
In JSF2 that’s possible by using
<h:outputStylesheet>or<h:outputScipt>anywhere in your template or composite component. JSF will take care about putting it in the generated HTML<head>.E.g.
in combination with those files in
/resourcesfolder of the webcontent./resources/css/specific.css/resources/js/specific.jsAlso, in a JSF2
UIComponentyou can force loading of specific resources using the@ResourceDependencyor@ResourceDependenciesannotation.So whenever you use
<custom:componentWithCSS>in your view code, JSF2 will include the annotated resources in the generated HTML<head>.