在Birt处理程序上使用Javascript reportContext.setPersistentGlobalVariable方法在进程之间传递对象 [英] Using Javascript reportContext.setPersistentGlobalVariable method on Birt handlers To pass objects between processes

查看:116
本文介绍了在Birt处理程序上使用Javascript reportContext.setPersistentGlobalVariable方法在进程之间传递对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将变量从工厂过程传递到运行过程, 在eclipsde UI透视图中使用reportContext.setPersistentGlobalVariable. 在数据集的onFetch()中,代码如下所示:

I trying to pass variable from the factory process to the run process , using reportContext.setPersistentGlobalVariable in the eclipsde UI perspective. In the onFetch() of the data set the code look like this:

var flag = "hello";
reportContext.setPersistentGlobalVariable("flag", flag);

在报表设计的beforeRender()方法中,代码如下所示:

In the beforeRender() method of the report design the code look like this:

var flg = reportContext.getPersistentGlobalVariable("flag");
reportContext.getDesignHandle().findElement("text").setContent(flg);

应该注意的是,当我将两个代码片段放在两个报表设计中的..()方法上时,此代码才有效. 数据在两个进程之间不以某种方式传递.

It should be noted that this code is works when I put the two snippets in two of the report design on..() methods. Somehow the data not pass between the two processes.

推荐答案

我能够重现与您描述的行为类似的行为.请尝试在报表末尾插入一个动态文本元素并设置此表达式,它应该可以工作:

I was able to reproduce a behavior similar to what you describe. Please try to insert a Dynamic text element at the end of the report and set this expression, it should work:

reportContext.getPersistentGlobalVariable("flag");

您的报告很有可能正在运行一个独特的"RunAndRender"任务,而如果我们想利用beforeRender& onRender事件我们应该使用两个单独的运行"和渲染"任务.

Most likely your reports are running with a unique "RunAndRender" task, whereas if we want to take advantage of beforeRender & onRender events we should use two separate "Run" and "Render" task.

在Eclipse Designer中,如果使用Web Viewer运行报告(在Web Viewer中查看报告"),则有两个单独的任务,但是如果我们直接运行导出(将报告查看为xxx"),则只有一个任务.任务.

In practice with Eclipse Designer, if we run reports using the Web Viewer ("View report in Web Viewer") there are two separate tasks but if we directly run an export ("View report as xxx") there is a single task.

也就是说,重要的是要注意处理渲染事件是很棘手的:在大多数情况下,在这里尝试更改designHandle元素为时已晚.例如,即使元素的可见性"属性也无法在渲染时更改.不过,您可以使用此元素的"onRender"事件来更改文本的内容:

That said, it is important to notice handling render events is tricky: most of the time it is too late to change designHandle elements as you try to do here. Even the "visibility" property of elements can't be changed at render time, for example. You can change the content of a text using "onRender" event of this element though:

this.text=reportContext.getPersistentGlobalVariable("flag");

这篇关于在Birt处理程序上使用Javascript reportContext.setPersistentGlobalVariable方法在进程之间传递对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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