Primefaces进入按键关闭对话框

时间:2011-03-25 05:09:01

标签: primefaces

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

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

2 个答案:

答案 0 :(得分:0)

你可以用Javascript来做。很久以前就问过similiar question with a variety of answers

Primefaces拥有它自己的(或一些改编的JQuery / YUI)javascript捆绑。不知道它是如何与自制的js相互作用的。试一试!

答案 1 :(得分:0)

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