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!

Comments:

"p:" to provoke all the PrimeFaces fans out there..? :-)

Posted by Martin Kofoed on June 24, 2013 at 02:47 PM CEST #

especially for Java EE UI: Have a look at CatainCasa http://captaincasa.com/
server-centric JavaFX and Swing UI framework

Posted by Dan on June 24, 2013 at 03:05 PM CEST #

Good news but sad choice for the namespace prefix. Did somebody at Oracle thought that many of us use PrimeFaces and that unfortunately that "p:" was already taken?

Posted by Andrea Pucci on June 26, 2013 at 01:39 PM CEST #

@Martin Kofoed
@Andrea Pucci

Are you aware that the "p" is not fixed? if you already use th p prefix for PrimeFaces you can simply change the declaration to:

xmlns:ph="http://xmlns.jcp.org/jsf/passthrough"

and use "ph" as the prefix...

Posted by Rivas on June 27, 2013 at 09:06 AM CEST #

Well, PrimeFaces Team prefers pt for this;

http://blog.primefaces.org/?p=2714

Posted by Cagatay Civici on June 29, 2013 at 09:42 PM CEST #

Hi Adam,

How can i passthrough a placeholder with the value been read from a resource bundle for i18n having it not to be escaped?

Ej:
someProperty=<hi world>

<h: inputText .... p:placeholder="#i18n['someProperty']" />

By default someProperty it's gonna be escaped so '<' and '>' are gonna be encoded

Posted by Joaquin Moreira on July 31, 2013 at 01:30 AM CEST #

Hello!

I am beginner of Java EE 7. Now I am learning JSF 2.2 by using Glassfish 4.0 and Eclipse. While I writing HTML5 support JSF 2.2, eclipse validator show a warning message that they can't find the name space xmlns:ph="http://xmlns.jcp.org/jsf/passthrough". How can I solve this problem.

Regards

Posted by Min Lwin on September 17, 2013 at 01:20 AM CEST #

Thanks, nice tip

Posted by Binh Nguyen on June 19, 2015 at 08:15 AM CEST #

I have mental problems.

Posted by Man on August 20, 2015 at 03:00 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License