簡體   English   中英

來自提交按鈕的事件序列

[英]Sequence of events from a submit button

我有一個簡單的測試頁,我正在嘗試處理事件序列以及如何處理querySaveDocument故障。

據我所見,事件的順序是

  1. 提交的點擊
  2. 驗證
  3. querySaveDocument
  4. 保存文件

在Submit操作中,我返回“成功”,但是無論querySave返回true還是false,都會發生這種情況。 現在,我想做的是,如果querySave失敗,則返回與驗證相同的相同文檔。 因此,我相信在onclick事件中設置返回“成功”是導致問題的原因,但是我該如何捕獲querySaveDocument,如果失敗,則只需返回即可,否則執行“成功”導航。

這應該沒有那么困難,但是我認為這是因為querySaveDocument是一個后端事件。 但我認為這種過程將是人們經常做的事情。 我想在驗證后執行querySave,因為僅當准備好要保存文檔時,嘗試執行相當涉及的querySaveDocument事件沒有任何意義。 我想到做一個onComplete事件中的提交按鈕返回,但這似乎不起作用。 ??

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.navigationRules>
        <xp:navigationRule outcome="success" viewId="xpMain.xsp">
        </xp:navigationRule>
    </xp:this.navigationRules>
    <xp:button value="Submit" id="button1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="complete" immediate="false" save="true">
            <xp:this.action><![CDATA[#{javascript:println("In Submit")
return 'success';}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>
    <xp:br></xp:br>
    <xp:br></xp:br>
    Required Field&#160;
    <xp:inputText id="inputText1" value="#{document1.BusinessUnit}">
        <xp:this.validators>
            <xp:validateRequired message="Please enter a value"></xp:validateRequired>
        </xp:this.validators>
        <xp:this.required><![CDATA[#{javascript:println("In Validation");
return "This is a requiedd Field";}]]>
        </xp:this.required>
    </xp:inputText>
    <xp:this.data>
        <xp:dominoDocument databaseName="Client Apps\LGI\LGI Rules.nsf"
            formName="frmCLRule" var="document1">
            <xp:this.querySaveDocument>
        <![CDATA[#{javascript:println("In QuerySave");
return false;}]]>
            </xp:this.querySaveDocument>
        </xp:dominoDocument>
    </xp:this.data>
    <xp:br></xp:br>
    <xp:br></xp:br>
</xp:view>

當我運行代碼時,我看到執行的順序是Submit事件,querySaveDocument和導航規則。

在querySaveDocument事件中使用viewScope變量來記錄成功或失敗,然后在navigationRule中使用它。 下面的示例代碼。

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.navigationRules>
        <xp:navigationRule viewId="xpMain.xsp">
            <xp:this.outcome><![CDATA[#{javascript:if ( viewScope.qrySave ) {
    return 'success';
}}]]></xp:this.outcome>
        </xp:navigationRule>
    </xp:this.navigationRules>
    <xp:button value="Submit" id="button1">
        <xp:eventHandler event="onclick" submit="true"
            refreshMode="complete" immediate="false" save="true">
            <xp:this.action><![CDATA[#{javascript:println("In Submit")
return 'success';}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>
    <xp:br></xp:br>
    <xp:br></xp:br>
    Required Field&#160;
    <xp:inputText id="inputText1" value="#{document1.BusinessUnit}">
        <xp:this.validators>
            <xp:validateRequired message="Please enter a value"></xp:validateRequired>
        </xp:this.validators>
        <xp:this.required><![CDATA[#{javascript:println("In Validation");
return "This is a requiedd Field";}]]>
        </xp:this.required>
    </xp:inputText>
    <xp:this.data>
        <xp:dominoDocument databaseName="Client Apps\LGI\LGI Rules.nsf"
            formName="frmCLRule" var="document1">
            <xp:this.querySaveDocument>
        <![CDATA[#{javascript:println("In QuerySave");
viewScope.qrySave = false;
//viewScope.qrySave = true;
return false;}]]>
            </xp:this.querySaveDocument>
        </xp:dominoDocument>
    </xp:this.data>
    <xp:br></xp:br>
    <xp:br></xp:br>
</xp:view>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM