Birt脚本通过Web查看器的行为有所不同 [英] Birt script behaves differently via web viewer

查看:83
本文介绍了Birt脚本通过Web查看器的行为有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法通过网络运行Birt报告.在html中运行时,该报告的行为符合预期,但是某些脚本无法通过Web查看器正常运行.我已经在报告的初始化"阶段运行了这个脚本(我知道很多行不是必需的,只是想确保我摆脱了任何可能的脚本语法错误):

i'm having trouble running a birt report via web. The report behaves as expected when running in html, but some scripts are not working properly via web viewer. I've got this script running on the "initialize" phase of the report (i know that a lot of the lines are not neccessary, just want be sure I got rid of any possible scripting syntax errors):

var inc_number;
var inc_number_old;
var contador;
var grupo;
var proveedor;
var contador_no_encaminadas;
var contador_encaminadas;
var contador_cerradas;
var estado;
var cliente_nombre;
var cliente_apellido;
contador = 0;
contador_no_encaminadas = 0;
contador_encaminadas = 0;
contador_cerradas = 0;
inc_number_old = 0;

然后我在表行中运行了另一个小脚本,使用了onRender触发功能:

And then i've got another little script running in a table row, with onRender triggering:

inc_number =  row["Incident Number"];
grupo = row["Assigned Group"];
proveedor = row["Vendor Name"];
estado = row["Status"];
cliente_nombre = row["First Name"];
cliente_apellido = row["Last Name"];

if (inc_number != inc_number_old){

    contador++;

    if (proveedor != null && grupo != "SIGMA")
        contador_encaminadas++;

    if ((proveedor == null || proveedor == "") && (grupo == "SIGMA") && (estado != "Resolved" && estado != "Closed"))
        contador_no_encaminadas++;

    if (estado == "Resolved" || estado == "Closed")
        contador_cerradas++;
}   

inc_number_old = inc_number;

vars["contador_cerradas"] = contador_cerradas;
vars["contador_incidencias"] = contador;
vars["contador_no_encaminadas"] = contador_no_encaminadas;
vars["contador_encaminadas"] = contador_encaminadas;

您可能已经注意到,所有这些仅用于显示不同的计数集.我在一个表中设置了一些Data字段来调用此变量(上一代码块的最后四行),因此报告显示了该计数.好吧,当通过工作区中的预览"选项卡运行时,或在运行"菜单中单击html选项时,所有这些都可以完美运行,但是当我尝试通过Web查看器运行时,所有计数都显示为0(可能是默认值).变量的值).如果有人可以在这方面给我一些帮助,我将非常感激.无论如何,无论我选择了哪种预览选项,我都在单元格上运行了其他脚本onRender,这些脚本都可以正常工作.

As you may have noticed, all of this is just for displaying different sets of counts. I set some Data fields in a table calling for this variables (last four lines of the previous code block) so the report shows this counts. Well, all of this works perfectly when running via the preview tab in the workspace, or hitting the html option in the "Run" menu, but when I try to run it via web viewer, all of the counts display 0 (probably the default value of the variables). I'd be very thankful if anyone could give me some help in this. Somehow I've got some other scripts running on cells, onRender too, that are working ok regardless the preview option I choose.

p.s.我正在使用Birt v2.5.1,我知道它有点旧,但这是唯一与BMC Remedy ARS集成的受支持版本,这就是我需要的版本.谢谢!

p.s. I'm working with Birt v2.5.1, I know it's a bit old, but it's the only supported version to integrate with BMC Remedy ARS, and that's what I need it for. Thanks!!

推荐答案

BIRT对于直接"输出具有不同的脚本流,对于Web Viewer具有不同的脚本流.报告有两个创建阶段:生成"和演示",请参见 BIRT事件流程图.在直接"生成中,事件onCreateonRender被混合并在生成阶段一起触发(onCreate行1; onRender行1; onCreate行2; onRender行2等). initialize脚本首先执行一次.

BIRT has different script flows for "direct" output and different for Web Viewer. There are two report creation phases: "generation" and "presentation", see BIRT events flow diagrams. In "direct" generation onCreate and onRender events are mixed and triggered together through generation phase (onCreate row 1 ; onRender row 1 ; onCreate row 2 ; onRender row 2 etc.). initialize script is exeuted once, before all.

相反,Web Viewer将生成和表示阶段分为两个阶段:首先执行所有onCreate,然后实际上关闭报表(认为所有脚本数据都丢失了"),然后执行所有onRender. initialize执行两次,第一次在生成阶段之前(onCreate),第二次在呈现阶段之前(onRender). onRender可能无权访问row['...']变量,但有权访问它的报表元素属性,例如this.foo.

In opposite, Web Viewer has split generation and presentation phases: first all onCreate are executed, then report is virtually closed (think "all script data is lost"), then all onRender are executed. initialize is executed twice, first time before generation phase (onCreate), second time before presentation phase (onRender). onRender may not have access to row['...'] variables, but have access to it's report element attributes, like this.foo.

最好将所有数据处理都放在onCreate脚本中,而不是在onRender脚本中,因为脚本变量保持在一个一致的阶段.演示文稿中,某些页面 可能会被忽略(我不确定),因此在Web查看器中的页面之间跳转时,可能有错误的结果.

It is good to have all data manipulation in onCreate rather than onRender script, because script variables are kept in one consistent phase. Presentation, for some pages may be ommited (I'm not sure), so you may have wrong results when jumping between pages in web viewer.

如果必须在生成和表示阶段之间传递一些数据,则必须将其存储在持久性全局变量中:

If you have to pass some data between generation and presentation phase, you have to store it in persistent global variable:

setPersistentGlobalVariable("name", value); //in generation phase
...
var value = getPersistentGlobalVariable("name"); //in presentation phase

仅在上面的函数中,无需在报表设计器中定义该变量.使用持久性全局变量时,可能只会遇到一个小陷阱-它们必须在Java中可序列化(对于某些Java数据类型,这不是明显的功能).

There is no need to define that variable in Report Designer, just use functions above. Only one small trap may be encountered when using persistent global variables - they must be serializable in Java (it is not obvious feature for some Java data types).

这篇关于Birt脚本通过Web查看器的行为有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆