2011-03-25 158 views
1

當打開下面的對話框並且用戶點擊輸入時,它關閉。我假設我需要以某種方式添加一些屬性到下面的命令按鈕,當用戶輸入時不允許它提交。任何想法?Primefaces輸入密鑰關閉對話框

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

回答

0

爲了解決這個問題,我必須確保關閉按鈕是表單中最後一個按鈕。

0

你可以使用Javascript做到這一點。 A similiar question with a variety of answers已經被問過一段時間了。

Primefaces擁有它自己的(或一些改編的JQuery/YUI)javascript捆綁。不知道它是如何與自制的js相互作用的。試一試!