【问题标题】:JSF and placeholder jsf 2.2 [duplicate]JSF 和占位符 jsf 2.2 [重复]
【发布时间】:2014-07-14 02:43:44
【问题描述】:

我在 javaee 项目中使用 jsf 2.2,我想为我的输入文本使用占位符,所以这就是我使用的。

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

但这不起作用,我也尝试过

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

希望你能帮助我。

【问题讨论】:

    标签: jsf placeholder


    【解决方案1】:

    使用以下属性为您的标签添加占位符:

    p:placeholder="test"
    

    但是ph 是什么?
    您需要在视图文件的开头声明正确的标签库:

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

    生成的输出将是:

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

    但请仔细检查您是否使用的是 jsf 2.2(这在较低版本中可能不起作用)

    【讨论】:

      【解决方案2】:

      将 xmlns 添加到页眉:

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

      并像下面这样使用它:

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

      【讨论】:

        猜你喜欢
        • 2014-05-21
        • 2013-04-10
        • 2013-01-04
        • 2018-06-12
        • 1970-01-01
        • 2014-05-10
        • 1970-01-01
        • 2014-04-28
        • 1970-01-01
        相关资源
        最近更新 更多