本文主要是介绍jsp页面点击页签自动刷新解决方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题:在一个projectInfoMain.jsp的界面定义了多个页签,怎么实现在一个页签的jsp页面保存完以后点击每个页签时自动刷新改界面。
解决方案:可以在每次点击页签时,修改页签的url地址,使它再次向服务器发送请求,以实现自动刷新的功能
具体解决方案:
projectInfoMain.jsp主界面实现代码:
<%@ page language="java" contentType="text/html; charset=GBK"%><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%><%@ taglib uri="/WEB-INF/cvicse-param.tld" prefix="param"%><%@ taglib uri="/WEB-INF/cvicse-common.tld" prefix="common"%><%@ taglib uri="http://www.cvicse.com/tags-webui" prefix="webui"%><%response.setHeader("Pragma", "no-cache");response.setHeader("Cache-Control", "no-cache");response.setDateHeader("Expires", 0);String showFlag = (String)request.getAttribute("showFlag");String path=request.getContextPath();%><html><head><title>项目信息</title><webui:dojo /><common:theme/><script>function flush(prjnodd,flg){if(prjnodd==""){return;}with(document.forms(0)){//防止页面不刷新URL添加时间var time = new Date(); if(""==prjnoid.value){prjnoid.value=prjnodd;tabpage1.tabPage.url="<%=request.getContextPath()%>/dc/projectInfoAction.do?operAtt=addPrj&prjno="+document.getElementById("prjnoid").value+"&time="+time;tabpage2.tabPage.url="<%=request.getContextPath()%>/dc/retamtModelAction.do?prjno="+document.getElementById("prjnoid").value+"&time="+time;tabpage4.tabPage.url="<%=request.getContextPath()%>/dc/schemeQueryAction.do?operAtt=queryIrr&isClose=1&prjno="+document.getElementById("prjnoid").value+"&time="+time;tabpage5.tabPage.url="<%=request.getContextPath()%>/dc/schemeQueryAction.do?operAtt=queryIrr&ajustFlag=1&isClose=1&prjno="+document.getElementById("prjnoid").value+"&time="+time;}else if(flg!="0"){if(flg=="1"){tabpage2.tabPage.url="<%=request.getContextPath()%>/dc/retamtModelAction.do?prjno="+document.getElementById("prjnoid").value+"&time="+time;}if(flg=="2"){tabpage1.tabPage.url="<%=request.getContextPath()%>/dc/projectInfoAction.do?operAtt=addPrj&prjno="+document.getElementById("prjnoid").value+"&time="+time;} tabpage4.tabPage.url="<%=request.getContextPath()%>/dc/schemeQueryAction.do?operAtt=queryIrr&isClose=1&prjno="+document.getElementById("prjnoid").value+"&time="+time;tabpage5.tabPage.url="<%=request.getContextPath()%>/dc/schemeQueryAction.do?operAtt=queryIrr&ajustFlag=1&isClose=1&prjno="+document.getElementById("prjnoid").value+"&time="+time;}}}function toBack(){document.location.href="/lbms/dc/projectInfoAction.do";}function getProjectId(){with(document.forms(0)){return prjnoid.value;}}function changeEvent(){dojo.require("xcom._base.event");xcom.publish("dc.prjSave", [ {saveState :"success"}, window ]);}</script></head><body style="width:100%;height:100%;overflow:hidden;margin:0em" ><common:form action="projectInfoAction.do"><common:hidden name="projectinfoForm" property="operAtt"/><common:hidden name="projectinfoForm" property="prjno" styleId="prjnoid"/><table style="width:100%;height:100%" cellpadding="0" border="0" cellspacing="0"><tr> <td><common:tabpane styleId="tabpane1"cookie="false"><common:tabpage styleId="tabpage1" title="报价台账基本信息">projectInfoAction.do?operAtt=addPrj&prjno=<bean:write name="projectinfoForm" property="prjno"/></common:tabpage><common:tabpage styleId="tabpage2" title="约定还款明细">retamtModelAction.do?prjno='+document.getElementById("prjnoid").value+'</common:tabpage><common:tabpage styleId="tabpage3" title="租金计划表">retamtTabAction.do?operAtt=query&queryFlg=1&isShow=1&prjno='+document.getElementById("prjnoid").value+'</common:tabpage></common:tabpane></td></tr></table></common:form></body></html>
举出一个页签对应的jsp页面
<%@ page language="java" contentType="text/html; charset=GBK"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/cvicse-param.tld" prefix="param"%>
<%@ taglib uri="/WEB-INF/cvicse-common.tld" prefix="common"%>
<%@ taglib uri="http://www.cvicse.com/tags-webui" prefix="webui"%>
<%@ taglib uri="http://www.cvicse.com/tags-event" prefix="event"%>
<%@page import="com.cvicse.lms.smn.retamt.action.RetamtModelForm"%><%response.setHeader("Pragma", "no-cache");response.setHeader("Cache-Control", "no-cache");response.setDateHeader("Expires", 0);String path=request.getContextPath();
%>
<%RetamtModelForm retamtModelForm = (RetamtModelForm) request.getAttribute("retamtModelForm");//System.out.println(retamtModelForm.getRevRateStr());
%>
<html>
<head>
<script language="JavaScript" src="<%=path%>/js/ajaxbase.js"></script>
<common:theme />
<webui:dojo />
<script type="text/javascript"> dojo.addOnLoad(function() { parent.changeEvent();xcom.subscribe("dc.prjSave", null, function(event, source) {//alert(event.saveState);if (event.saveState == "success") {document.forms[0].validatorGroup.needValidate = false;document.forms[0].validatorGroup.needEmptyValidate = false;document.forms[0].operAtt.value="";with(document.forms(0)){if(prjno.value==""){prjno.value=parent.getProjectId();}}document.forms[0].submit();}});});
function changeEvent(){dojo.require("xcom._base.event");xcom.publish("dc.prjvSave", [ {saveState :"success"}, window ]);dojo.require("xcom._base.event");xcom.publish("dc.retSave", [ {saveState :"success"}, window ]);dojo.require("xcom._base.event");xcom.publish("dc.irrSave", [ {saveState :"success1"}, window ]);}
function toQuery(){ document.forms[0].validatorGroup.needValidate = false;document.forms[0].validatorGroup.needEmptyValidate = false;document.forms[0].operAtt.value="";with(document.forms(0)){if(prjno.value==""){prjno.value=parent.getProjectId();}}document.forms[0].submit();
}
function toBack(){parent.toBack();
}
</script>
<title></title></head>
<body style="width: 100%; height: 100%; margin: 0em" >
<common:form action="retamtModelAction.do"></common:form>
<script>var editableTable = null;function toSave() {with (document.forms(0)) {operAtt.value = "saveLx";submit();}parent.changeEvent();parent.flush(document.getElementById('prjno').value,"2");}}
</script>
</body>
</html>
这篇关于jsp页面点击页签自动刷新解决方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!