Is there anyway to use bootstrap related tags in JSF2 components? For example I’m interested in using the bootstrap typeahead feature which requires something like
<h:inputText id="typeahead" type="text" data-provide="typeahead"></h:inputText>
but since data-provide doesn’t exist for h:inputText it gets stripped out and so the typeahead feature would obviously not work.
Depends on JSF version you’re using.
In JSF 2.0/2.1, it’s not possible to specify additional attributes. The JSF HTML renderers will only render predefined attributes. You’d need to create a custom renderer to achieve the desired job. To minimize boilerplate code, you’re forced to extend the implementation-specific renderer. It’s unclear which one you’re using, so here’s just a Mojarra targeted example:
Register it as follows in
faces-config.xmlto get it to run:In JSF 2.2, it’s possible by the new
passthroughnamespace or the<f:passThroughAttribute>tag. See also What’s new in JSF 2.2? – HTML5 Pass-through attributes.Thus, so:
(note that the
typeattribute defaults totextalready)Or:
See also: