我有一个使用xagent发布的文档(可以对文档执行各种操作)。
在发送给xagent之前,我想询问用户他是否希望将文档的生效日期设置为今天的日期。目前,我没有在页面上以编辑模式提供该字段,但我想我需要它。
最大的问题是如何询问确认(您希望将日期设置为今天吗?)并在实际保存文档并将其发送到xagent页面之前将日期放在字段中。我已经在该保存按钮中有一些简单的操作。这是代码:
<xp:button value="Save and Publish" id="button6">
<xp:this.rendered><![CDATA[#{javascript:database.queryAccessRoles(session.getEffectiveUserName()).contains('[Admin]') && currentDocument.isEditable()}]]></xp:this.rendered>
<xp:eventHandler event="onclick" submit="true"
refreshMode="complete">
<xp:this.action>
<xp:actionGroup>
<xp:modifyField name="Status" var="pageDocument">
<xp:this.value><![CDATA[#{javascript:if(getComponent("publishLater1").getValue() == "1") {
return "Scheduled Publication";
} else {
return "To Be Published";
}}]]></xp:this.value>
</xp:modifyField>
<xp:saveDocument var="pageDocument">
</xp:saveDocument>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript: //remove the lock doc
//unlockDoc(pageDocument.getDocument().getUniversalID());
//for scheduled publications, a LotusScript agent will do the work
var res=facesContext.getExternalContext().getResponse();
if(getComponent("publishLater1").getValue() == "0") {
// Now load the publish Agent
res.sendRedirect(@Left(facesContext.getExternalContext().getRequestContextPath(),".nsf")+".nsf/xPublish?OpenAgent&docid=" + pageDocument.getDocument().getUniversalID());
} else {
//send to the drafts view, to show it has the clock icon in the draft view
res.sendRedirect(@Left(facesContext.getExternalContext().getRequestContextPath(),".nsf")+".nsf/adminDrafts.xsp");
} }]]></xp:this.script>
</xp:executeScript>
</xp:actionGroup>
</xp:this.action>
</xp:eventHandler>
<i class="fa fa-newspaper-o pull-left fa-2x">
</i>
</xp:button>
答案 0 :(得分:2)
你可以用我想的几种方式来做。如果您正在使用扩展库,则可以使用dialogBox。因此,您的保存和发布按钮会打开一个包含您的问题或其他字段的对话框。然后你在对话框中添加一个取消按钮,还有一个“继续”按钮。如果您输入任何内容或者知道他们想要“今天”日期然后该按钮调用xagent传递任何适当的参数,该按钮将访问这些字段。
答案 1 :(得分:1)
据推测,pageDocument
是一个dominoDocument数据源。 dominoDocument数据源要么全部只读,要么全部可编辑。 SSJS可以访问该数据源。因此,添加另一个executeScript
操作,您也可以修改您想要的任何其他字段。
但我建议的是跳过简单的操作并在脚本中执行所有操作。 SSJS编辑器允许您查看dominoDocument数据源的所有可用方法。通过对LotusScript或稍微调查的一点了解,应该明白使用哪种方法替换“修改字段”简单操作的项值(快速提示,再次转到数据源而不是publishLater1
组件)以及保存文档的方法。如果您开始摆脱简单的行动并建立对SSJS的信心,从长远来看,它将为您提供更大的灵活性。