2

我使用了 Primefaces 日历组件,它在表单中不起作用。当我单击文本字段时,弹出窗口一显示就迅速消失。外部h:form弹出窗口正在显示,但整体组件仍然无法像月/年那样工作,不能选择。不建议为什么?

以下是我的advSearch.xhtml小脸,其模板是Master.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 <ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/MasterPage/Master.xhtml">

<ui:define name="Search">

    <h:form id="advSearch" onmousemove="removeExtra()">

            <p:layout style="width:1218px;height:558px;" id="layout">



                <p:layoutUnit position="center" styleClass="resultDiv">

                    <div class="advDiv">

                        <div class="advHeader">Find documents That Have...</div>
                        <div class="advBody">

                            <table>
                                <tr>
                                    <td><h:outputText styleClass="advLabel" value="Subject"></h:outputText></td>
                                    <td><h:inputText
                                            value="#{advanceSearchController.subject}"
                                            styleClass="txtfield"
                                            onkeypress="if (event.keyCode == 13) { document.getElementById('advSearch:advButton').click(); return false; }"></h:inputText>
                                    </td>
                                </tr>


                                <tr>
                                    <td><h:outputText styleClass="advLabel" value="Signed By"></h:outputText></td>
                                    <td><h:inputText
                                            value="#{advanceSearchController.signBy}"
                                            styleClass="txtfield"
                                            onkeypress="if (event.keyCode == 13) { document.getElementById('advSearch:advButton').click(); return false; }"></h:inputText></td>
                                </tr>
                                <tr>
                                    <td><h:outputText styleClass="advLabel"
                                            value="Archived From"></h:outputText></td>
                                    <td><p:calendar styleClass="txtfield" mode="popup"
                                            navigator="true" yearRange="1900:2015" pattern="MM/dd/yyyy"
                                            converter="CalendarDateStringConverter"
                                            value="#{advanceSearchController.fromdate}" /></td>
                                </tr>
                                <tr>
                                    <td><h:outputText styleClass="advLabel" value="To"></h:outputText></td>
                                    <td><p:calendar styleClass="txtfield" mode="popup"
                                            navigator="true" yearRange="1900:2015" pattern="MM/dd/yyyy"
                                            converter="CalendarDateStringConverter"
                                            value="#{advanceSearchController.todate}" /></td>
                                </tr>
                            </table>
                            <h:commandButton id="advButton" styleClass="btn"
                                value="Advanced Search"
                                action="#{advanceSearchController.advanceSearch}"
                                style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold;"></h:commandButton>
                        </div>
                    </div>

                </p:layoutUnit>
            </p:layout>
        </div>

    </h:form>

</ui:define>

任何帮助将不胜感激。

4

1 回答 1

0

代码看起来不错,但有一件事,我只看到您onmousemove="removeExtra()"在表单上调用的 JS 函数。
正如您所说,弹出窗口很快消失意味着它来了然后又消失了。这表明日历工作正常,但其他地方有问题。
请检查两件事
(1)当您在日历字段中单击后移动光标时字段是否消失(意味着只需单击并查看它是否消失,如果没有则移动光标然后检查因为您调用了您的 JS 函数 onmouseover 事件所以它可能是鼠标移动问题)
(2)删除这个removeExtra()函数,然后检查

于 2013-03-19T11:01:29.867 回答