我在我的 Xpage 上使用事件处理程序来保存我的数据源(frmData):
<xp:eventHandler
id="saveEventHandler"
submit="true"
save="true"
event="calledbyid"
refreshMode="complete"
>
<xp:this.action><![CDATA[#{javascript:frmData.save();
context.redirectToPage("index.xsp")}]]></xp:this.action>
</xp:eventHandler>
这由自定义属性调用:
<xe:basicLeafNode
onClick="XSP.executeOnServer('#{id:saveEventHandler}')"
label="Save"
rendered="#{javascript:currentDocument.isEditable()}"
>
</xe:basicLeafNode>
这是客户端到服务器站点触发器的 Jeremy Hodge 先生代码:
XSP.executeOnServer = function () {
// must supply event handler id or we're outta here....
if (!arguments[0])
return false;
// the ID of the event handler we want to execute
var functionName = arguments[0];
// OPTIONAL - The Client Side ID that you want to partial refresh after executing the event handler
var refreshId = (arguments[1]) ? arguments[1] : "@none";
var form = (arguments[1]) ? this.findForm(arguments[1]) : dojo.query('form')[0];
// catch all in case dojo element has moved object outside of form...
if (!form)
form = dojo.query('form')[0];
// OPTIONAL - Options object contianing onStart, onComplete and onError functions for the call to the
// handler and subsequent partial refresh
var options = (arguments[2]) ? arguments[2] : {};
// OPTIONAL - Value to submit in $$xspsubmitvalue. can be retrieved using context.getSubmittedValue()
var submitValue = (arguments[3]) ? arguments[3] : '';
// Set the ID in $$xspsubmitid of the event handler to execute
dojo.query('[name="$$xspsubmitid"]')[0].value = functionName;
dojo.query('[name="$$xspsubmitvalue"]')[0].value = submitValue;
this._partialRefresh("post", form, refreshId, options);
}
表单上的所有字段值都已保存,但富文本项除外。
当我使用简单的按钮 onclick 事件而不是使用上面的处理程序时,保存了富文本项!
<xp:button
value="Label"
id="button1"
xp:key="facet_3"
>
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="complete"
>
<xp:this.action>
<xp:saveDocument
var="frmData"
>
</xp:saveDocument>
</xp:this.action>
</xp:eventHandler>
</xp:button>
请让我知道如何处理这个事件处理程序?
-麦