Primefaces “输入关键点”对话框关闭

Primefaces “输入关键点”对话框关闭,primefaces,Primefaces,当下面的对话框打开且用户点击enter时,它将关闭。我假设我需要以某种方式为下面的commandButton添加一些属性,以便在用户点击enter时不允许它提交。有什么想法吗 <p:dialog header="#{bundle['dreamSearch.HEADER']}" widgetVar="webSearchDlg" modal="true" styleClass="dialog dialog2" draggable="false" resizabl

当下面的对话框打开且用户点击enter时,它将关闭。我假设我需要以某种方式为下面的commandButton添加一些属性,以便在用户点击enter时不允许它提交。有什么想法吗

<p:dialog header="#{bundle['dreamSearch.HEADER']}"
        widgetVar="webSearchDlg" modal="true" styleClass="dialog dialog2"
        draggable="false" resizable="false" showEffect="fade"
        hideEffect="fade">
        <h:form id="dreamWebSearchFrm">
        <div class="dialog-top-reg"></div>
        <div class="dialog-middle-reg">
        <div><p:commandButton styleClass="close zoom3" onclick="webSearchDlg.hide()" /></div>
            <div class="dialog-content dialog-content2">
                <h1 class="dream-search">
                    <h:outputText value="#{bundle['dreamSearch.HEADER']}" />
                </h1>
                <p class="dream-search">
                    <h:outputText value="#{bundle['dreamSearch.SUBHEADER']}" />
                </p>
                <p:panel id="searchTextPnl">
                    <div class="dream-search-wrap">
                        <fieldset>
                            <p:inputText id="searchText" value="#{dreamSearchBean.searchText}"/>
                            <p:commandButton tabindex="-1" styleClass="form-btn1" value="#{bundle['dreamSearch.search.button.TEXT']}" 
                            actionListener="#{dreamSearch.search}" update=":dreamWebSearchFrm:resultsPnl"/>
                        </fieldset>
                    </div>
                </p:panel>
                <p:panel id="resultsPnl">
                    <div class="data-grid-wrap">
                    <h:outputFormat escape="false" value="#{bundle['dreamSearch.imageResults.TEXT']}" rendered="#{dreamSearchBean.shouldRender}">
                        <f:param value="#{dreamSearchBean.searchText}" />
                    </h:outputFormat>
                        <p:dataGrid var="dream" value="#{dreamSearchBean.dreams}" rendered="#{dreamSearchBean.shouldRender}" columns="5"
                            rows="10" paginator="true" effect="true"
                            styleClass="ui-header-visibility"
                            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                            rowsPerPageTemplate="10,15,20" paginatorPosition="bottom">
                            <p:column>
                                <h:panelGrid columns="1" style="width:100%">
                                    <p:commandLink onclick="webSearchDlg.hide();dreamEditDlg.show();" update=":dreamEditFrm:display"> 
                                        <f:setPropertyActionListener value="#{dream}" target="#{dreamModifyBean.selectedDream}"/>
                                        <f:setPropertyActionListener value="false" target="#{dreamModifyBean.editLink}"/>
                                        <p:graphicImage value="#{dream.imageThumb}" width="100" height="100" />
                                    </p:commandLink>
                                </h:panelGrid>
                            </p:column>
                        </p:dataGrid>
                    </div>
                </p:panel>
            </div>
        </div>
        <div class="dialog-bottom-reg"></div>
    </h:form>   
    </p:dialog>


您可以使用Javascript来完成。一段时间前有人问了一个问题


Primefaces捆绑了自己的(或一些经过调整的JQuery/YUI)javascript。不知道它如何与自制的js交互。试试看

为了解决这个问题,我必须确保关闭按钮是表单中的最后一个按钮