我有一个简单的测试页面,我正在尝试通过事件序列以及如何处理querySaveDocument失败。
据我所知,事件的顺序是
在提交操作中,我返回'success',但无论querySave是返回true还是false,都会发生这种情况。现在我想要做的是,如果querySave失败,则以与验证相同的方式返回同一文档。所以我认为在onclick事件中设置返回'成功'是导致问题的原因,但是如何捕获querySaveDocument以及如果失败则返回,否则执行'success'导航。
这应该不是那么困难,但我认为这是因为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 
<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>
答案 0 :(得分:1)
当我运行代码时,我看到执行的顺序是提交事件,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 
<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>