Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Difference between PersistentGlobalVariable and GlobalVariable
Ben
Hi, all.
I wrote a simple sample, using java code to deal with some business rules.
if(row.getColumnValue("title").toString().equals("BL"))
{
reportContext.setPersistentGlobalVariable("xx", "1");
}else
{
reportContext.setPersistentGlobalVariable("xx", "1");
}
If I use reportContext.setGlobalVariable("xx", "1"), I can not get thie value in other Event Handlers, but persistentGlobalVariable works well?
Could you please tell me what's the differences?? Thanks....:)
Find more posts tagged with
Comments
Davolio
I don't know if this is your question but if I do assign a global
reportContext.setGlobalVariable("prevUserId","Dave");
then I want to access my variable anywhere else all I do it this to get the value
reportContext.getGlobalVariable("prevUserId")
I don't know the difference between the setPersistentGlobalVariable and the setGlobalVariable though and that would be nice to know
.
mwilliams
Hi Ben,<br />
<br />
I don't know if the description on the documentation page helps you out at all, but here it is:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.com/documentation/BIRT_220/EngineJavadoc/enginescript/api/org/eclipse/birt/report/engine/api/script/IReportContext.html'>IReportContext
(Birt Script API)</a><br />
<br />
When I use global variables, I usually use the persistentGlobalVariable.<br />
<br />
If I find any more information out. I'll post it in here.
Davolio
After reading the documentation, I found this to be a great reference for understanding the phases etc when scripting in birt.<br />
<br />
I found this to be worth book marking or printing off the charts and sticking them on my cube wall
.<br />
<br />
<a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php'>Report
Scripting</a><br />
<br />
Hope that's useful,<br />
<br />
Dave
JasonW
The difference is that the persistence call stores the variable in the rptdocument, so if you generation is separted into two phases ( by seconds or days) the only way to pass the variable value across is to persist it. Otherwise it is only available in the one phase.
HTH
Jason
Cheong Hoong Jun
<blockquote class="ipsBlockquote" data-author="Davolio" data-cid="39842" data-time="1228223461">
<div>
<p>I don't know if this is your question but if I do assign a global reportContext.setGlobalVariable("prevUserId","Dave"); then I want to access my variable anywhere else all I do it this to get the value reportContext.getGlobalVariable("prevUserId") I don't know the difference between the setPersistentGlobalVariable and the setGlobalVariable though and that would be nice to know
.</p>
</div>
</blockquote>
<p> :wacko:</p>
Cheong Hoong Jun
<p>1. reportContext.setGlobalVariable scopes the variable for one phase </p>
<p> </p>
<p>2. reportContext.setPersistentGlobalVariable scopes for both phases and writes the variable into the rptdocument.</p>
<ul><li>The variable must be a serializable object</li>
<li>Persisted variables are not stored in the render phase only the generation phase</li>
<li>Most often used when a chart script needs a variable that is created in a normal report item.</li>
</ul>