JSF 2.0 strips out needed HTML5 attributes [duplicate]
I work with a JSF team doing the front end development. We're outputting an INPUT field and I need to include placeholder
and a few data-
attributes into the rendered tag. The JSF is stripping these out, however. I don't know JSF enough to be of much help to the JSF team, but thought I could at least ask around.
We were using an older version of JSF but upgraded to 2.0 as it appeared that it would support HTML5. Is that not the case? Is the开发者_如何学运维re a known way to work around this?
JSF isn't exactly stripping them out. It's just ignoring them because they are not among the supported/known attributes of the component in question. In case of for example <h:inputText>
(which renders by default a HTML <input type="text">
tag), you can find all supported attributes in the view declaration language (VDL) documentation.
To overcome this, you would need to create a custom component or, better, just a custom renderer which overrides the standard <h:inputText>
renderer and takes the custom attributes into account.
If you are using Facelet you can simply write in the HTML5 components the EL expression.
For example video:
<video name="myVideo" poster="#{bean.poster}" >
<source src="#{bean.vidoeSrc}" type='video/ogg; codecs="theora, vorbis"' />
</video>
This way you can use ANY HTML5 component - and the binding will be to JSF as other JSF components. you can also use the same idea in input element of HTML.
EDITED
For placeholder you can use PrimeFaces inplace. Check out their components for more details.
精彩评论