Reputation: 1060
I am trying to use PrimeFaces inputText text box to get user input. Even I add placeholder attribute, the text is not appearing in the text box. Is there any library I need to include for this? below is my jsf page.
<ui:composition template="/template/master-layout.xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<ui:define name="head"> test header </ui:define>
<ui:define name="meta">
<f:metadata>
<f:event type="preRenderView" listener="#{HomeBean.initPage}"></f:event>
</f:metadata>
</ui:define>
<ui:define name="mainContainer">
<div class="row">
<div class="col-sm-12">
<p:inputText placeholder="Your ID" styleClass="form-control service-input-border" maxlength="20" id="Id"
value="#{homeBean.Id}"></p:inputText>
</div>
</div>
</ui:define>
</ui:composition>
Upvotes: 0
Views: 2585
Reputation: 2091
Apostolos answer is good, but I prefer using passthrough attributes. You can use them if you're using JSF >= JSF 2.2.
Just use new namaspace http://xmlns.jcp.org/jsf/passthrough
and use any HTML attribute you like (e.g. any which is not added to the input/compoment). In your case it will be placeholder
.
<ui:composition template="/template/master-layout.xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
<!-- ... -->
<p:inputText pt:placeholder="Your ID" styleClass="form-control service-input-border"
maxlength="20" id="Id" value="#{homeBean.Id}" />
You can read more about passthrough attributes here and here.
Upvotes: 2