JSF taglib is very helpful to build HTML forms and reports. Not all W3C’s attributes are available in standard tags. The h:inputText does not contains the attribute “placeholder”, available only in HTML5.

To make up this “limitation” without overwriting a component or building a new one, JSF 2.2 has the “workaround” called Pass Through Attributes. A new tag to inhibit to remove any custom attributes.

Declare tag using xmlns:p=”http://xmlns.jcp.org/jsf/passthrough”. Now, you can put “p:” in any JSF tag as attribute, like “<h:outputText p:MyAttribute=”MyValue” … />”. This will write “<input type=”text” MyAttribute=”MyValue” … />”.

Go to work:

JSF without Pass Through

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html">
	<h:head>
	</h:head>
	<h:body>
		<f:view contentType="text/html">
			<h:form>
				<!-- Numeric input text and placeholder attribute -->
				<h:inputText ... placeholder="Age" type="number" />
			</h:form>
		</f:view>
	</h:body>
</html>

There is not “placeholder” attribute

With Pass Through

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:p="http://xmlns.jcp.org/jsf/passthrough">
	<h:head>
	</h:head>
	<h:body>
		<f:view contentType="text/html">
			<h:form>
				<!-- Numeric input text and placeholder attribute -->
				<h:inputText ... p:placeholder="Age" p:type="number" />
			</h:form>
		</f:view>
	</h:body>
</html>
There is "placeholder" attribute

There is “placeholder” attribute