繁体   English   中英

<p:watermark>在生成的HTML源文件中未解析

[英]<p:watermark> appears unparsed in generated HTML source

我正在使用JSF 2.0。 我一直在尝试为输入文本呈现一个占位符,并且我正在尝试primefaces的水印。 这是jsf代码

<html xmlns="http://www.w3.org/1999/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:c="http://java.sun.com/jstl/core"
      xmlns:p="http://primefaces.org/ui">
....
....
<h:form>
    <table>
        <thead>
            <tr>
                <th>
                    <h:outputText value="Header"/>
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <h:inputText id="first" value="#{bean.firstValue}"/>
                    <p:watermark for="first" value="Fill me"/>
                </td>
            </tr>
        </tbody>
    </table>
</h:form>

这是它的呈现方式:

<form id="j_id_1v" name="j_id_1v" method="post" action"/mypage/app/main.xhtml" enctype="application/x-www-form-urlencoded">
    <table>
        <thead>
            <tr>
                <th>
                    "Header"
                </th>
            </tr>
        </thead>
        <tbody>
            <input id="j_id_1v:first" name="j_id_1v:first" type="text" value>
            <p:watermark for="first" value="Fill me"></p:watermark>
        </tbody>
    </table>
</form>

#{bean.firstValue}中的值为null 不知道这是否可以,还是应该为空字符串。 问题在于渲染的输入字段为空。 没有水印。 我究竟做错了什么?

您还需要添加primefaces jar,就像添加JSF jar一样

PS如果你想使用水印,你可以只使用一个jQuery水印插件 ...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM