function addDev()
{
var sFeatures="dialogWidth:700px;dialogHeight:500px;scroll:no;";
var customerId = document.all['cusId'].value;
var result= window.showModalDialog('<%=appURL %>/businesspermit/DeviceSelectAction.do?formAction=toAddPage&customerId='+customerId,"",sFeatures);
if(result!=null )
{
<logic:present name="edit" scope="request">
document.CustomerSetForm.action="<%=appURL %>/businesspermit/CustomerSetAction.do?formAction=toEditBusi&showType=1";
</logic:present>
<logic:notPresent name="edit" scope="request">
document.CustomerSetForm.action="<%=appURL %>/businesspermit/CustomerSetAction.do?formAction=getBusinessSet";
</logic:notPresent>
// window.location.reload();
CustomerSetForm.submit();
}
}
這個(gè)函數(shù)表示:添加新的設(shè)備JS函數(shù),window.showModalDialog()會(huì)返回一個(gè)值result,如果result!=null,則刷新這個(gè)頁(yè)面。
原來(lái)是用window.location.reload();刷新頁(yè)面的,但是這樣就不能保留之前頁(yè)面上輸入的數(shù)據(jù),為了保留原來(lái)輸入的數(shù)據(jù),換成了
document.CustomerSetForm.action=“”;
CustomerSetForm.submit();
上面的語(yǔ)句表示:讓這個(gè)頁(yè)面重新指向另一個(gè)action地址,然后提交。這樣,用了Struts標(biāo)簽后,以前四輸入的數(shù)據(jù)仍然會(huì)保留到返回后的頁(yè)面了。
注意:在js代碼中,可能使用譬如說(shuō)<logic:present>等標(biāo)簽。