adam bien's blog

JSF 2.2 and HTML 5 Placeholder (Passthrough) 📎

The Java EE 7 version of JSF (2.2) enables the definition of any arbitrary attributes, which are not going to be processed by the JSF runtime and directly passed to the browser.

However, you will have to declare an additional namespace and qualify the attribute with the namespace:


<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://xmlns.jcp.org/jsf/passthrough">

  <!-- ... -->
  <h:inputText value="#{index.message}" p:placeholder="write something"/>
  <!-- ... -->

The generated output is:


<input type="text" name="j_idt9:j_idt10:j_idt11" placeholder="write something">

See you at Java EE Workshops at MUC Airport, especially at Java EE UI!