Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

h:inputText - jsf does not render the placeholder

I want to create a landingPage and I want to save the data in my database through jsf 2.0 and Primefaces 3.5

My page *.xhtml page looks like this:

enter image description here

However, I want to make it look like my HTML page:

enter image description here

Besides the CSS my h:inputText should contain a placeholder. My code looks like this:

<h:form class="homepage_invitee_form" action="" method="POST">
    <h:inputText name="email" placeholder="Email Address"
                 id="email_address_new" type="text placeholder" />
    <br />
    <h:inputText name="firstName" placeholder="First Name"
                 id="firstname_new" type="text placeholder" />
    <h:inputText name="lastName" placeholder="Last Name"
                 id="lastname_new" type="text placeholder" />
    <br />
    <h:button value="Request Invitation" type="submit" class="btn btn-primary opal_btn"
              id="submit_form_new" />
</h:form>

As you can see the placeholder attribute doesn't get rendered. I would really appreciate any idea as to how to render that properly.

UPDATE

My HTML code looks like this:

<form class="homepage_invitee_form" action="" method="POST">
    <input name="email" placeholder="Email Address" id="email_address_new" type="text placeholder"><br>
    <input name="firstName" placeholder="First Name" id="firstname_new" type="text placeholder">
    <input name="lastName" placeholder="Last Name" id="lastname_new" type="text placeholder"><br> 
    <button type="submit" class="btn btn-primary opal_btn" id="submit_form_new">Request Invitation</button>
</form>
like image 408
maximus Avatar asked Apr 17 '13 13:04

maximus


2 Answers

Use p:watermark in xhtml instead of your placeholders. Other visual design is totally about your css.

Here look at this primefaces showcase

like image 56
oko Avatar answered Oct 23 '22 05:10

oko


For JSF 2.2 (JEE 7), you can use the namespace

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

then use it e.g.:

<h:inputText value="#{bean.field}" p:placeholder="supply value"/>

This passes it through to the generated HTML (NB: HTML 5 attribute).

See http://www.adam-bien.com/roller/abien/entry/jsf_2_2_and_html .

like image 8
frIT Avatar answered Oct 23 '22 03:10

frIT