利用JavaScript修改Cognos默认等待界面
资料简介:
2010-12-20 更新了8.4的脚本文件在附件中,如果用cognos8.4的可以下载for8.4的
我已经更新的脚本,大家重新下载一下脚本替换上去看看效果,现在可以修改报表首次展现时等待界面没有修改成功的问题。感谢 光风霁月 和 cog的积极支持,谢谢各位网友的积极回复。
经常有网友在坛子里问如何修改cognos默认的等待界面,之前我也在8.3下实现了,对默认等待和报错界面的修改,但是代码的入侵性较高,也有网友反映不好用。下午有看了一下,改写了一下cognos viewer所用的js文件,只是将默认的等待界面改了,出错界面还没有处理。
效果如下
如果CognosViewer的入口是CGI方式,请求的是c8_locationwebcontentrv文件夹下的文件
如果入口时Servlet方式是则请求的是c8_locationwebappsp2pdrv文件夹下的文件
我是以p2pd为例,方法如下:
打开c8_locationwebappsp2pdrvCCognosViewer.js
找到createWaitPageDiv 方法,该方法是创建等待框的DVI,通过改写其DIV的生成内容实现对默认界面的修改
CCognosViewer.prototype.processResponseState = function(oState)
{
this.setStatus(oState.status);
this.setConversation(oState.conversation);
this.setTracking(oState.tracking);
this.setCAFContext(oState.caf);
this.setExecutionParameters(oState.parameters);
this.setSecondaryRequests(oState.secondaryRequests);
this.setSessionPrompts(oState.session_prompts);
this.setActionState(oState.action_state);
if(typeof oState.clientunencodedexecutionparameters != "undefined")
{
var formWarpRequest = document.getElementById("formWarpRequest" + this.getId());
if(formWarpRequest != null && typeof formWarpRequest["clientunencodedexecutionparameters"] != "undefined")
{
formWarpRequest["clientunencodedexecutionparameters"].value = oState.clientunencodedexecutionparameters;
}
if(typeof document.forms["formWarpRequest"] != "undefined" && typeof document.forms["formWarpRequest"]["clientunencodedexecutionparameters"] != "undefined")
{
document.forms["formWarpRequest"]["clientunencodedexecutionparameters"].value = oState.clientunencodedexecutionparameters;
}
}
if (oState.sResponseSpecification)
{
this.updateResponseSpecification(oState.sResponseSpecification);
}
if(typeof this.envParams != "undefined")
{
this.envParams["ui.primaryAction"] = oState.primary_action;
}
if(this.getStatus() == "complete")
{
this.m_undoStack.push(new CognosViewerSession(this));
}
//fengdong modify this to change default wait page
var oReportDiv = document.getElementById("CVReport" + this.getId());
if (oState.status == "working" || oState.status == "stillWorking" || oState.status == "default")
{
if (oState.status == "working" || oState.status == "default")
{
if (typeof oReportDiv != 'undefined' && oReportDiv != null)
{
var divs = oReportDiv.getElementsByTagName("DIV");
var hidDiv;
for(var i=0; i< divs.length; i++)
{
if(divs.className == "body_dialog_modal")
{
hidDiv = divs[i];
hidDiv.style.display = "none";
hidDiv.parentNode.parentNode.parentNode.parentNode.style.borderStyle = "none";
hidDiv.parentNode.innerHTML = "" + hidDiv.parentNode.innerHTML;
break;
}
}
}[/i][i]
this.m_waitPage.show(this.bIsSavedReport);
}
// add a delay for this callback to allow the server request to clean up, and not block any futher server requests
setTimeout("oCV"+this.getId()+".executeCallback("wait");",10);
}
else if(oState.status == "cancel")
{
this.executeCallback("cancel");
}
else if (oState.status == "fault")
{
this.setSoapFault(oState.soapFault);
this.m_waitPage.hide();
this.executeCallback("fault");
}
else
{
if (oState.status != "prompting" || !this.executeCallback("prompt"))
{
if (this.rvMainWnd)
{
this.writeNavLinks(oState.secondaryRequests.join(" "));
this.updateLayout(oState.status);
var oToolbar = this.rvMainWnd.getToolbar();
if (oToolbar)
{
this.rvMainWnd.updateToolbar(oState.outputFormat);
oToolbar.draw();
}
var oBannerToolber = this.rvMainWnd.getBannerToolbar();
if (oBannerToolber)
{
oBannerToolber.draw();
}
}
this.m_waitPage.hide();
this.executeCallback("done");
}
}
if (typeof oReportDiv != 'undefined' && oReportDiv != null)
{
oReportDiv.style.display = '';
}
};
//下面的代码是生成等待层
WaitPage.prototype.createWaitPageDiv = function(bSavedReport)
{
var oWaitDiv = document.createElement("DIV");
oWaitDiv.setAttribute("id", "CVWait" + this.getNamespace());
oWaitDiv.style.position = "absolute";
oWaitDiv.style.textAlign = "center";
oWaitDiv.style.zIndex = 100;
document.body.appendChild(oWaitDiv);
try
{
oWaitDiv.innerHTML = " ";
}
catch (oExcpt) {}
return oWaitDiv;
};
上面的示例代码是8.3环境的,将代码中红色的部分替换过去,再将等待的gif图片放到rv文件夹即可。8.4环境也可以参考相应位置,进行修改
我将代码和图片上传到了论坛上,附件中包含了CCognosViewer.js和图片
如果用cgi方式将rv文件夹覆盖到c8_locationwebcontent文件夹下
如果用servlet方式则将rv文件夹覆盖到c8_locationwebappsp2pd文件夹下
cognos8.3的JS文件
[/i][i]
cognos8.4的js文件
[/i]
我已经更新的脚本,大家重新下载一下脚本替换上去看看效果,现在可以修改报表首次展现时等待界面没有修改成功的问题。感谢 光风霁月 和 cog的积极支持,谢谢各位网友的积极回复。
经常有网友在坛子里问如何修改cognos默认的等待界面,之前我也在8.3下实现了,对默认等待和报错界面的修改,但是代码的入侵性较高,也有网友反映不好用。下午有看了一下,改写了一下cognos viewer所用的js文件,只是将默认的等待界面改了,出错界面还没有处理。
效果如下
如果CognosViewer的入口是CGI方式,请求的是c8_locationwebcontentrv文件夹下的文件
如果入口时Servlet方式是则请求的是c8_locationwebappsp2pdrv文件夹下的文件
我是以p2pd为例,方法如下:
打开c8_locationwebappsp2pdrvCCognosViewer.js
找到createWaitPageDiv 方法,该方法是创建等待框的DVI,通过改写其DIV的生成内容实现对默认界面的修改
CCognosViewer.prototype.processResponseState = function(oState)
{
this.setStatus(oState.status);
this.setConversation(oState.conversation);
this.setTracking(oState.tracking);
this.setCAFContext(oState.caf);
this.setExecutionParameters(oState.parameters);
this.setSecondaryRequests(oState.secondaryRequests);
this.setSessionPrompts(oState.session_prompts);
this.setActionState(oState.action_state);
if(typeof oState.clientunencodedexecutionparameters != "undefined")
{
var formWarpRequest = document.getElementById("formWarpRequest" + this.getId());
if(formWarpRequest != null && typeof formWarpRequest["clientunencodedexecutionparameters"] != "undefined")
{
formWarpRequest["clientunencodedexecutionparameters"].value = oState.clientunencodedexecutionparameters;
}
if(typeof document.forms["formWarpRequest"] != "undefined" && typeof document.forms["formWarpRequest"]["clientunencodedexecutionparameters"] != "undefined")
{
document.forms["formWarpRequest"]["clientunencodedexecutionparameters"].value = oState.clientunencodedexecutionparameters;
}
}
if (oState.sResponseSpecification)
{
this.updateResponseSpecification(oState.sResponseSpecification);
}
if(typeof this.envParams != "undefined")
{
this.envParams["ui.primaryAction"] = oState.primary_action;
}
if(this.getStatus() == "complete")
{
this.m_undoStack.push(new CognosViewerSession(this));
}
//fengdong modify this to change default wait page
var oReportDiv = document.getElementById("CVReport" + this.getId());
if (oState.status == "working" || oState.status == "stillWorking" || oState.status == "default")
{
if (oState.status == "working" || oState.status == "default")
{
if (typeof oReportDiv != 'undefined' && oReportDiv != null)
{
var divs = oReportDiv.getElementsByTagName("DIV");
var hidDiv;
for(var i=0; i< divs.length; i++)
{
if(divs.className == "body_dialog_modal")
{
hidDiv = divs[i];
hidDiv.style.display = "none";
hidDiv.parentNode.parentNode.parentNode.parentNode.style.borderStyle = "none";
hidDiv.parentNode.innerHTML = "" + hidDiv.parentNode.innerHTML;
break;
}
}
}[/i][i]
this.m_waitPage.show(this.bIsSavedReport);
}
// add a delay for this callback to allow the server request to clean up, and not block any futher server requests
setTimeout("oCV"+this.getId()+".executeCallback("wait");",10);
}
else if(oState.status == "cancel")
{
this.executeCallback("cancel");
}
else if (oState.status == "fault")
{
this.setSoapFault(oState.soapFault);
this.m_waitPage.hide();
this.executeCallback("fault");
}
else
{
if (oState.status != "prompting" || !this.executeCallback("prompt"))
{
if (this.rvMainWnd)
{
this.writeNavLinks(oState.secondaryRequests.join(" "));
this.updateLayout(oState.status);
var oToolbar = this.rvMainWnd.getToolbar();
if (oToolbar)
{
this.rvMainWnd.updateToolbar(oState.outputFormat);
oToolbar.draw();
}
var oBannerToolber = this.rvMainWnd.getBannerToolbar();
if (oBannerToolber)
{
oBannerToolber.draw();
}
}
this.m_waitPage.hide();
this.executeCallback("done");
}
}
if (typeof oReportDiv != 'undefined' && oReportDiv != null)
{
oReportDiv.style.display = '';
}
};
//下面的代码是生成等待层
WaitPage.prototype.createWaitPageDiv = function(bSavedReport)
{
var oWaitDiv = document.createElement("DIV");
oWaitDiv.setAttribute("id", "CVWait" + this.getNamespace());
oWaitDiv.style.position = "absolute";
oWaitDiv.style.textAlign = "center";
oWaitDiv.style.zIndex = 100;
document.body.appendChild(oWaitDiv);
try
{
oWaitDiv.innerHTML = " ";
}
catch (oExcpt) {}
return oWaitDiv;
};
上面的示例代码是8.3环境的,将代码中红色的部分替换过去,再将等待的gif图片放到rv文件夹即可。8.4环境也可以参考相应位置,进行修改
我将代码和图片上传到了论坛上,附件中包含了CCognosViewer.js和图片
如果用cgi方式将rv文件夹覆盖到c8_locationwebcontent文件夹下
如果用servlet方式则将rv文件夹覆盖到c8_locationwebappsp2pd文件夹下
cognos8.3的JS文件
[/i][i]
cognos8.4的js文件
[/i]
2010-12-15
浏览409
下载146