我有一个XPage,它在 beforeRenderResponse 事件中具有代码,该代码可将数据导出到Excel。
我想让我从扩展库创建的“请稍候...”对话框出现在导出开始之前。我尝试了getComponent("dialogbox").show()
,但是在导出开始之前它似乎忽略了该行。
您对在SSJS或CSJS中如何在XPage上显示对话框有任何建议吗?预先感谢您的协助。
经过编辑以添加XPages和客户控制代码。
XPages代码:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false"
xmlns:xc="http://www.ibm.com/xsp/custom"
xmlns:xp_1="http://www.ibm.com/xsp/coreex">
<xp:this.resources>
<xp:script src="/Web Report Functions.jss" clientSide="false"></xp:script>
</xp:this.resources>
<xp:this.afterRenderResponse><![CDATA[#{javascript:/*...(export to excel code)...*/}]]></xp:this.afterRenderResponse>
<xc:WaitDialogBox></xc:WaitDialogBox>
<xp:scriptBlock id="showDialog">
<xp:this.value><![CDATA[XSP.addOnLoad(function(){XSP.openDialog("#{id:WaitDialog}");});]]></xp:this.value>
</xp:scriptBlock>
</xp:view>
自定义控制代码“ WaitDialogBox”:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xe="http://www.ibm.com/xsp/coreex">
<xe:dialog id="WaitDialog" title="Please wait...">
<xp:table>
<xp:tr>
<xp:td>
Processing....
<xp:br></xp:br>
<xp:br></xp:br>
Please wait until you see the "Do you want to open or save..." bar on the bottom of your screen.
<xp:br></xp:br>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="padding-top:10px;margin-top:10px;text-align:center;">
<xp:image url="/ajax-loader.gif" id="processImage"></xp:image>
</xp:td>
</xp:tr>
</xp:table></xe:dialog>
</xp:view>
答案 0 :(得分:0)
您是否只想在页面加载时显示“请稍等”消息?如果是这样的话,那么比《九点笔记》中的广播要更好。在这种情况下,您不想使用对话框。 http://www.notesin9.com/2014/04/07/notesin9-142-adding-a-please-wait-to-xpages/
答案 1 :(得分:0)
因此,如果要在运行导出时显示一条消息(无论是哪种消息,对话框或Howard建议的dojo备用数据库),则必须确保在不执行导出的情况下首先加载页面,然后启动然后导出。
在我的示例页面上,查看view标签上的rendered属性。我在那里检查请求网址上是否有参数export
。这也是在afterRenderResponse
事件开始时完成的。
然后在showDialog
脚本块中,打开对话框并通过添加?export=true
来更改当前窗口的url。您可以随意用其他任何内容替换对话框。使用此解决方案,在导出完成并可以下载时,无法执行某些操作(即关闭对话框)。
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
xmlns:xc="http://www.ibm.com/xsp/custom"
rendered="#{javascript:param.get('export') != 'true'}">
<xp:this.afterRenderResponse><![CDATA[#{javascript:
if(param.get('export') == 'true'){
/*...(export to excel code)...*/
}}]]></xp:this.afterRenderResponse>
<xc:WaitDialogBox></xc:WaitDialogBox>
<xp:scriptBlock id="showDialog">
<xp:this.value><![CDATA[
XSP.addOnLoad(function(){
XSP.openDialog("#{id:WaitDialog}");
location.href='#{javascript:return context.getUrl().getPath()}?export=true';
});]]></xp:this.value>
</xp:scriptBlock>
</xp:view>