|
版本: |
BeX5V3.5 |
小版本号: |
|
|
|
数据库: |
MySQL |
服务器操作系统: |
Windows |
应用服务器: |
Tomcat |
客户端操作系统: |
Windows 7 |
浏览器: |
Chrome |
|
|
代码如下:
Model.prototype.postBtnClick = function(event){
// 输出执行代码
TextOut.setText(code, arguments.callee.toString());
var form = this.getElementByXid("postForm");
var uploadFileName = this.getElementByXid("uploadFileName");
var uploadFile = this.getElementByXid("uploadFile");
var postResultIframe = this.getElementByXid("postResultIframe");
// form表单提交对应的请求URL是"$UI/system/service/common/bizAction.j",但提交前需要进行URL转换,在URL上补足bsessionid等必要信息
var url = require.toUrl("$UI/system/service/common/bizAction.j?bsessionid=" + this.getContext().getBSessionID());
// 将转换后的URL设置到form表单上
form.attributes["action"].value = url;
// 设置文件名参数域,文件名中的中文需要编码encodeURI,在Action的java中再解码decode
$(uploadFileName).val(window.encodeURI($(uploadFile).val()));
// 在form目标iframe的onload事件中以回调方式获取返回值
var parentWindow = window;
$(postResultIframe).load(function(){
alert("aaa");
var iframeWindow = this.contentWindow;
iframeWindow.setTimeout(function() {
var doc = iframeWindow.document.XMLDocument ? iframeWindow.document.XMLDocument : iframeWindow.document;
// 判断动作调用是否成功
var flag = $(doc).find("flag").text();
if (flag == "true") {
justep.Util.hint("form表单方式调用动作成功");
// 输出返回结果
var data = $(doc).find("data").text();
TextOut.setText(result, data);
} else {
justep.Util.hint("form表单方式调用动作失败");
// 抛出错误信息
var message = $(doc).find("message").text();
TextOut.setText(result, message);
}
}, 1);
});
// 提交表单
$(form).submit();
};
|
|