来自提交按钮的事件序列 [英] Sequence of events from a submit button

查看:26
本文介绍了来自提交按钮的事件序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的测试页面,我正在尝试处理事件序列以及如何处理 querySaveDocument 失败.

I have a simple test page that I'm trying work through the sequence of events and how to handle a querySaveDocument failure.

据我所知,事件的顺序是

As far as I can see the sequence of events is

  1. 点击提交
  2. 验证
  3. querySaveDocument
  4. 保存文档

在提交操作中,我返回成功",但无论 querySave 返回 true 还是 false,都会发生这种情况.现在我想要做的是,如果 querySave 失败,则以与验证相同的方式返回相同的文档.所以我相信在 onclick 事件中设置 return 'success' 是导致问题的原因,但是我如何捕获 querySaveDocument 并且如果它失败就返回,否则执行 'success' 导航.

in the submit action I return 'success' but that happens regardless of whether the querySave returns true or false. Now what I want to do is if the querySave fails return tio the same document the same way as the validation does. So I believe that setting the return 'success' in the onclick event is what is causing the problem but how do I trap the querySaveDocument and if it fails just return otherwise do the 'success' navigation.

这应该不难,但我认为这是因为 querySaveDocument 是一个后端事件.但我认为这种过程将是人们经常做的事情.我想在验证后执行 querySave,因为只有在文档准备好保存时才尝试执行相当复杂的 querySaveDocument 事件是没有意义的.我想过在 onComplete 事件中执行提交按钮返回,但这似乎不起作用.??

This should not be that difficult but I think it is because the querySaveDocument is a backend event. But I would think that this sort of process would be something that people would do pretty regularly. I want to do the querySave after the validation because there is no point in attempting to do a rather involved querySaveDocument event only if the document is ready to be saved. I thought of doing the submit button return in an onComplete event but that does not appear to work. ??

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

推荐答案

当我运行代码时,我看到执行顺序是提交事件,查询保存文档,然后是导航规则.

when i run the code, I see the order of execution is submit event, querySaveDocument and then navigation rule.

在 querySaveDocument 事件中使用 viewScope 变量来记录成功或失败,然后在 navigationRule 中使用它.示例代码如下.

Use a viewScope variable in querySaveDocument event to record success or failure and then use that in navigationRule. Sample code below.

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

这篇关于来自提交按钮的事件序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆