<%@ page contentType="text/html; charset=GBK" language="java"%>
<%@ page import="gap.rm.tools.helper.RmVoHelper"%>
<%@ taglib uri="reference" prefix="r"%>
<%@page import="sgcc.htjs.contract.util.IContractConstants"%>
<html>
<head>
<%@ include file="/jsp/include/global.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>編輯技術變動單</title>
<script language="javascript">
var rootPath = '<%=request.getContextPath()%>';//根路徑
$(document).ready(function() {
alert()
});
function upload_free_file(){
$("#con_edit_form").get(0).action = "<%=request.getContextPath()%>/ConChangeApplyAction.do?cmd=ajaxFormSubmit";
$("#con_edit_form").get(0).target = "form_iframe";//修改form重定到iframe中,模擬異步上傳文件的效果
try{
$('#con_edit_form').get(0).encoding = "multipart/form-data"; //IE+
}catch(err){
$("#con_edit_form").get(0).enctype = "multipart/form-data";
}
$("#con_edit_form").submit();
}
$(document).ready(function() {
$("#form_iframe").get(0).onload = function(){
debugger;
//得到返回的json信息等
var result_str = $("#form_iframe").get(0).contentWindow.document.body.innerHTML;
if(!result_str){
result_str = $("#form_iframe").get(0).contentWindow.document.documentElement.innerHTML;
}
alert(result_str);
}
});
//save
function conApplySave(){
$("#con_edit_form").get(0).action = "<%=request.getContextPath()%>/ConChangeApplyAction.do?cmd=conApplySave";
try{
$("#con_edit_form").get(0).enctype = "";
}catch(err){
}
try{
$('#con_edit_form').get(0).encoding = "";//IE+
}catch(err){
}
$("#con_edit_form").submit();
}
//這種方式能夠實現ifram不刷新頁面,異步上傳文件的效果,並能完成驗證。
/**
//frame上傳驗證數據
public IForward ajaxFormSubmit(DefaultForm formBean, IRequest request, IResponse response) throws Exception {
String jsonString = "";
HttpServletRequest hRequest=(HttpServletRequest) request.getServletRequest();
//建立上傳附件解析器,目前只支持默認建立
FileUploador fu = FileUploadorFactory.createInstance();
try {
//判斷是否文件二進制提交
fu.parse(hRequest);
//設置最大隻容許附件大小
fu.setSizeMax(10*1024*1024*10); //100M
String test_x = fu.getParamterString("test_x");
//獲取附件對象.
//若是附件對象不存在,或者大小、類型不符合要求,則返回null
FileInfo fi = fu.getFileInfo("free_filename");
if(null != fi){
InputStream file_in = fi.getFile();
POIFSFileSystem pois = new POIFSFileSystem(file_in);
HSSFWorkbook wb = new HSSFWorkbook(pois);
HSSFSheet sheet = wb.getSheetAt(0);
int length=sheet.getLastRowNum();
String str = sheet.getRow(0).getCell(0).toString();
System.out.println(str);
jsonString = "{'status':'200','contractinfo_id':'121212212','result':'"+str+"'}";
}
} catch (Exception e) {
e.printStackTrace();
jsonString = "{'status':'203','contractinfo_id':'121212212','result':''}";
}
TooolUtil.setTextAjax(jsonString,response);
return null;
}
public IForward conApplySave(DefaultForm formBean, IRequest request, IResponse response) throws Exception {
String test_x = request.getParameter("test_x");
System.out.println(test_x);
return request.findForward("con_change_list");
}
*/
</script>
</head>
<body>
<script language="javascript">
writeTableTop('列表頁面','<%=request.getContextPath()%>/'); //顯示本頁的頁眉
</script>
<form name="con_edit_form" id="con_edit_form" enctype="multipart/form-data" method="post">
<input type="hidden" name="cmd" value="ajaxFormSubmit"/>
<input type="text" name="test_x" value=""/>
<input type="file" name="filename" value=""/>
<input name="button_return" id="button_return"
class="button_ellipse" type="button" value="提交"
onclick="javascript:upload_free_file();">javascript
</form>
<script language="javascript">
writeTableBottom('<%=request.getContextPath()%>/'); //顯示本頁的頁腳
</script>
</body>
</html>
<script language="javascript">
<% //表單回寫
if(request.getAttribute(IContractConstants.REQUEST_WRITE_BACK_FORM_VALUES) != null) { //若是request中取出的表單回寫bean不爲空
out.print(RmVoHelper.writeBackMapToForm((java.util.Map)request.getAttribute(IContractConstants.REQUEST_WRITE_BACK_FORM_VALUES))); //輸出表單回寫方法的腳本
}
%>
</script>
html