2013-08-06 26 views
0

我有使用view.postscript像這樣的的XPage:使用view.postscript XPages中

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

但是當我點擊按鈕,烤麪包機不能show.Why? 我需要一種方法來顯示由ssjs函數調用的烤麪包機。 非常感謝。

+1

將事件更改爲id = button1的部分。 –

回答

1

正如@Frantisek Kossuth所說,你正在重新提交該頁面。當refreshMode完成後,它將根據服務器值重新呈現頁面。如果您想在客戶端進行客戶端更改並將其反映出來,則無法進行完整刷新。對不會更改的元素(如button1)進行部分頁面刷新時,應更新UI而不重新構建頁面。

同樣,爲什麼你需要通過SSJS來完成這項工作?爲什麼不在客戶端按鈕激活中使用客戶端操作?如果這不是您不包括的較大函數調用的一部分,只需將事件代碼從服務器更改爲客戶端,並以此方式調用Toaster函數。這也可以讓你不必提交任何東西,在你的eventHandler中留下submit =「false」來避免不必要的功能。