A simple and clean way of how to enable “placeholder” and “type” HTML5 attributes in JSF components!
I’ve been working with JSF for almost a year, and sometimes standard components are not enough for rendering rich HTML5 pages.
For example, if we need to have a placeholder attribute on a particular HTML5 input element, we just write:
Unfortunately, standard JSF 2 library’s component InputText was designed for HTML4 and doesn’t support attribute ‘placeholder’ (as well as other non-standard attributes, such as ‘autofocus’, ‘autocomplete’). So, the following code won’t work because the ‘placeholder’ attribute will be ignored by standard JSF TextRenderer.
What if we really need to have placeholder in our input components? One solution would be using third-party libraries, such as PrimeFaces, or RichFaces. The provide placeholder (they call it ‘Water Mark’) and a lot of other features out of the box.
This solution has its drawbacks. Third-party libraries (like PrimeFaces) are quite difficult to cusomize, for the one thing. Besides, they have got their own…
View original post 188 more words