0

I am using jsf 2.2 in javaee project, i want to use a placeholder for my input text so that's what i used.

     <h:inputText id="nom" value="#{InscriptionBean.nom}" placeholder="test">
     </h:inputText>

but that's not working i also tried

     <h:inputText id="nom" value="#{InscriptionBean.nom}" h:placeholder="test">
     </h:inputText>

Hope you can help me.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

2 Answers2

4

Use the following attribute to add a placeholder to your tag:

p:placeholder="test"

But what are p and h?
You need to declare the right tag library at the start of your view file:

<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">

The generated output would be:

<input type="text" id="nom" name="nom" placeholder="test">

But double check if you are using jsf 2.2 (this may not work in lower versions)

GingerHead
  • 8,130
  • 15
  • 59
  • 93
0

Add xmlns to page header :

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

and use it like following :

<h:inputText id="nom" value="#{InscriptionBean.nom}" t:placeholder="test" />
Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40
or123456
  • 2,091
  • 8
  • 28
  • 50