2013-04-17 77 views
7

我想創建一個的LandingPage,我想通過JSF 2.0和Primefaces保存在我的數據庫中的數據3.5H:inputText的 - JSF不會呈現佔位符

我的頁面* .xhtml頁面看起來是這樣的:

enter image description here

不過,我想使它看起來像我的HTML頁面:

enter image description here

除了我的h:inputText CSS應該包含一個佔位符。我的代碼如下所示:

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

正如您所看到的,佔位符屬性不會呈現。我真的很感激任何想法如何正確呈現。

UPDATE

我的HTML代碼如下所示:

<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> 
+1

答案就在這裏: http://stackoverflow.com/questions/8494264 /在那裏 - 是最佔位符文本正在進行-時,使用的JSF和-的inputText – NeplatnyUdaj

回答

10

使用號碼:水印在XHTML,而不是你的佔位符。其他的視覺設計完全關乎你的CSS。

這裏看看這個primefaces showcase

8

對於JSF 2.2(JEE 7),就可以使用該命名空間

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

然後使用它如:

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

這將它傳遞給生成的HTML(注:HTML 屬性)。

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

0

我遇到了同樣的問題並修復了它。您可能沒有在該標籤上使用正確的xmln名稱空間。

確保「h」xmln名稱空間映射到PrimeFaces。通常將其映射到「http://java.sun.com/jsf/html」,並且xmln命名空間「p」通常映射到PrimeFaces「http://primefaces.org/ui」。如果你有正常的映射,那麼你就需要替換「h」上的代碼改變xmln到「P」:

 

    <h:form class="homepage_invitee_form" action="" method="POST"> 
     <p:inputText name="email" placeholder="Email Address" 
     id="email_address_new" type="text placeholder" /> 
     <br /> 
     ...