What are the benefits of using JSF2 resources?
Should I use JSF2 resources instead of plain html like <link href...
or url(image.png)
? What are the benefits? For me this is a bit annoying when web-designer 开发者_如何学Ccreates layout with XHTML, CSS and all that stuff and I need to spend time to replace plain HTML paths and tags to JSF resource tags like#{resource[...]}
.
Is there any other way? Like to put all CSS/image files in web root and use normal links?
Your choice.
The major benefit is that you can declare them on a per-component basis. If you need to include them on every single page anyway, then the benefit is little. But if you need to include component-specific CSS/JS code in for example a composite component which is reused more than once in a single view, then for example an <h:outputScript>
in a composite component would end up in it being included only once instead of that many times as the composite component is been used as would happen with <script>
. The same applies to the @ResourceDependency
annotation on real UIComponent
classes.
Please note that you are not required to use JSF2 resources only. Just plain vanilla <img>
, <link>
, <script>
, etc is also perfectly fine. It can even point to the JSF resources folder.
精彩评论