在xpages中使用view.postscript

在xpages中使用view.postscript,xpages,Xpages,我有一个使用view.postscript的xpage,如下所示: <?xml version="1.0" encoding="UTF-8"?> <xp:view xmlns:xp="http://www.ibm.com/xsp/core"> <xp:this.resources> <xp:dojoModule name="dojox.widget.Toaster"></xp:dojoModule> <xp:styleShe

我有一个使用view.postscript的xpage,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
 <xp:this.resources>
 <xp:dojoModule name="dojox.widget.Toaster"></xp:dojoModule>
 <xp:styleSheet href="/.ibmxspres/dojoroot/dojox/widget/Toaster/Toaster.css"></xp:styleSheet>
 </xp:this.resources>

 <xp:scriptBlock id="scriptBlock1">
 <xp:this.value><![CDATA[var Toaster = function(id, msg, type, duration, pos) {
 type = (type == null) ? "message" : type;
 duration = (duration == null) ? "5000" : duration;
 pos = (pos == null) ? "br-up" : pos;

 var obj = dijit.byId(id);
 obj.positionDirection = pos;
 obj.setContent(msg, type, duration);
 obj.show();
}]]></xp:this.value>
 </xp:scriptBlock>

 <xp:div id="toaster" themeId="toaster" dojoType="dojox.widget.Toaster"></xp:div>

 <xp:button value="Toaster" id="button1">
 <xp:eventHandler event="onclick" submit="true"
 refreshMode="complete">
 <xp:this.action><![CDATA[#{javascript:view.postScript("Toaster('"+getComponent("toaster").getClientId(facesContext)+"', 'toaster message!')");}]]></xp:this.action>
 </xp:eventHandler>
 </xp:button>
</xp:view>

但当我点击按钮时,烤面包机无法显示。为什么? 我需要一种方法来显示ssjs函数调用的烤面包机。
非常感谢。

正如@Frantisek Kossuth所说,您正在提交页面。刷新模式完成后,它将根据服务器值重新呈现页面。如果您希望进行客户端更改并在UI中反映这些更改,则无法刷新complete。在一个不会改变的元素(如button1)上部分刷新页面应该可以在不重建页面的情况下更新UI


类似地,为什么需要通过SSJS完成这项工作?为什么不在按钮激活中使用客户端操作?如果这不是您未包含的更大函数调用的一部分,只需将事件代码从服务器更改为客户端,并以这种方式调用Toaster函数。这还允许您不必提交任何内容,在eventHandler中保留submit=“false”以避免不必要的功能。

将事件更改为部分,id=button1。