Richfaces占位符不起作用

时间:2013-09-03 22:01:23

标签: jsf jsf-2 richfaces

我正在使用jsf 2.0,我正在尝试使用Richfaces 4.3的占位符。这是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:rich="http://richfaces.org/rich">
....
....
<h:form>
    <table>
        <thead>
            <tr>
                <th>
                    <h:outputText value="Header"/>
                </th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <h:inputText id="first" value="#{bean.firstValue}">
                        <rich:placeholder value="Fill me"/>
                    </h:inputText>
                </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>
        <tr>
            <td>
                <span id="j_id_1v:j_id_2r">
                    <script id="j_id_1v:j_id_2rScript" type="text/javascript">
                        <!--
                        new RichFaces.ui.Placeholder("j_id_1v:j_id_2r", {"targetId":"j_id_1v:first","text":"Fill me"} );
                        //-->
                    </script>
                </span>
                <input id="j_id_1v:first" name="j_id_1v:first" type="text" value>
            </td>
        </tr>
    </tbody>
</table>
</form>

#{bean.firstValue}“为空,不是空字符串。不确定这是否重要。问题是占位符文本没有显示。

有什么想法吗?

- EDIT-- 检查js控制台,它说“Richfaces未定义”。我敢肯定我正在使用richfaces 4.3。

2 个答案:

答案 0 :(得分:1)

好的,所以,经过大量的研究,我发现了它。事实证明,如果你使用<head>,jsf 2.0和richfaces就不会相处。您必须使用<h:head>,因此它会插入所有必需的依赖项。而且......就是这样!

答案 1 :(得分:1)

对我来说,曾为inputText添加ajax支持,例如

<h:inputText id="first" value="#{bean.firstValue}">
    <rich:placeholder value="Fill me"/>
    <a4j:ajax/>
</h:inputText>