When Should I Use Jsf Components And When Should I Use Html Tags?
,
Solution 1:
If you don't need the features provided by the JSF tag, I'd prefer to use plain HTML.
For example, <h:panelGroup> has a rendered attribute that allows you bind to a backing bean boolean variable to conditionally display the output, but with a <div> or <span>, you cannot do this.
The <h:panelGroup> will by default generate a <span>. If you prefer a <div>, then you can use <h:panelGroup layout="block">. It will generate a <div>for you .
Solution 2:
Just recent case from my practise:
1. for <p> and <div> you can't use rendered attribute
2. make your code more structural and solid - to be easy-readable for other users of your code
Solution 3:
There is a recommendation to not mix up jsf with html. Background: Then your jsf page can be rendered as something different than html. But as far as I know up till now there are only renderers for html (although you can write your own).
In practice I found it hard to follow this recommendation and ended up mixing html and jsf, e.g. for headings or line breaks I use html.
Solution 4:
As a general rule, I use a mix betweek HTML and Facelets tags in the layout pages. But for the actual content pages I try to only use the JSF tags available with my JSF library of choice (JSF + RichFaces).
That way I can have more control of which elements to show and hide, as well as the contents within each element, but I can still hard-code my main page layout in the facelets template file.
Post a Comment for "When Should I Use Jsf Components And When Should I Use Html Tags?"