2014-07-23 58 views
1

我有一個xe:對話框,其中包含Dojo表單控件,用於輸入多個值並在保存時創建一個新文檔。所有值都是必需的,我使用xe:djValidationTextBox,xe:djTimeTextBox,xe:djComboBox等組合來輸入值並執行客戶端驗證。無法關閉客戶端驗證XPE上的xe:對話框

這裏是輸入控件之一的一個示例:

    <xe:djValidationTextBox 
         id="djValidationTextBox2" value="#{document3.ChemTo}" 
         required="true" invalidMessage="Must enter the To change number" 
         promptMessage="Enter the To change number"> 
         <xe:this.converter> 
          <xp:convertNumber type="number"></xp:convertNumber> 
         </xe:this.converter> 
        </xe:djValidationTextBox> 

保存按鈕的偉大工程的所有驗證通過後,創建新文檔。

<xp:button value="Save" id="button7"> 
       <xp:eventHandler event="onclick" submit="true" 
        refreshMode="complete"> 
        <xp:this.action> 
         <xp:actionGroup> 
          <xp:saveDocument var="document3"> 
          </xp:saveDocument> 
          <xp:executeScript> 
           <xp:this.script><![CDATA[#{javascript:var c = `enter code here`getComponent("dialog1"); 
c.hide("panelChemLog");}]]></xp:this.script> 
          </xp:executeScript> 
         </xp:actionGroup> 
        </xp:this.action> 
       </xp:eventHandler> 
      </xp:button> 

問題出在取消按鈕。當我單擊「取消」按鈕時,仍然可以獲取所有必需的Dojo輸入控件的客戶端驗證消息,而不會顯示任何值。我可以通過單擊對話框右上角的大「X」來成功取消對話框,但無法關閉下面兩個取消按鈕的服務器端或客戶端代碼。

<xp:button value="Cancel CS" id="cancelButton"> 
       <xp:eventHandler event="onclick" submit="true" 
        refreshMode="complete"> 
        <xp:this.script><![CDATA[XSP.closeDialog("#{id:dialog1 }");]]> 
      </xp:this.script> 
       </xp:eventHandler> 
    </xp:button> 

      <xp:button value="Cancel SS" id="cancel2Button"> 
       <xp:eventHandler event="onclick" submit="true" 
        refreshMode="complete"> 
        <xp:this.action><![CDATA[#{javascript:var c =  
                getComponent("dialog1"); 
            c.hide();}]]></xp:this.action> 
       </xp:eventHandler> 
      </xp:button> 

如何編碼按鈕關閉對話框並繞過客戶端驗證?

+0

我的建議:做出關閉按鈕的自定義代碼,設置特定的標誌(隱藏編輯,JS變量)在CS驗證器中使用,以跳過驗證... –

回答

3

對於第二個按鈕(服務器端),可以通過immediate="true"屬性禁用驗證。

<xp:button 
    value="Cancel SS" 
    id="cancel2Button"> 
    <xp:eventHandler 
     event="onclick" 
     submit="true" 
     refreshMode="complete" immediate="true"> 
    <xp:this.action><![CDATA[#{javascript: 
    var c = getComponent("dialog1"); 
    c.hide();}]]></xp:this.action> 
    </xp:eventHandler> 
</xp:button> 

對於客戶端來說,這很有趣。如果你通過dojo-way隱藏對話框,它會正常關閉。我認爲這是因爲XSP.closeDialog()方法。此函數使用setTimeout()進行部分刷新相關問題,dojo組件在當時取消提交。

所以,只需在客戶端使用dijit.byId("#{id:dialog1}").hide();而不是XSP函數。

+0

謝謝Serder,這樣做......也很明顯。 –

+0

儘管這是一個部分解決方案。我已詳細查看過它,但無法找到在客戶端禁用Dojo驗證的簡單方法。我會更新,如果我能找到它。 :) –

+0

它就在那裏。我已經更新了客戶端的答案:) –

1

在onClick事件刷新完成後關閉對話框。
把XSP.closeDialog( 「#{ID:idName}」)在事件處理程序的事件的onComplete

< XP:this.action> < [CDATA [#{的javascript:VAR C = getComponent( 「dialog1」); c.hide();}]]> < /xp:this.action>

<xp:button value="Cancel SS" id="cancel2Button"> 
    <xp:eventHandler event="onclick" submit="true" 
        refreshMode="complete" immediate="true"> 
     <xp:this.onComplete><![CDATA[XSP.closeDialog("#{id:"dialog1"}")]]></xp:this.onComplete> 
    </xp:eventHandler> 
</xp:button>