Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Problem on set global variable(Problem passing varibles form onFetch and beforeDrawMarkerLine)
Problem on set global variable [message #1009160] Thu, 14 February 2013 15:13 Go to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Hi all,
i have this problem: on onFetch of one Data Set i insert one global varible like this:
reportContext.setPersistentGlobalVariable("MARKER_MIN","2");


in a chart i try to use this varible in this way:
function beforeDrawMarkerLine(axis, markerLine, icsc){
   importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
   importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
   var val=icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("MARKER_MIN");
   markerLine.setValue(NumberDataElementImpl.create(val)) ;
}

but i received this error:
Can't find method org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl.create(null).
I used also SetGlobalVariable and getGlobalVariable but i received the same error
what is wrong?
Re: Problem on set global variable [message #1009218 is a reply to message #1009160] Thu, 14 February 2013 17:33 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If you put this:
reportContext.setPersistentGlobalVariable("MARKER_MIN","2")

In the beforeFactory, do you have the same issue?

Jason
BIRT-Exchange
Re: Problem on set global variable [message #1009588 is a reply to message #1009218] Fri, 15 February 2013 10:55 Go to previous messageGo to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Hi,
now is ok, but i bind the query in a table in my header and now in the chart i get the correct data...it seems that the query is not fetched when i create my chart(in which i bind another query).
So, i have some dubt:
1) birt when execute the query, at binding to an object or at opening of report?
2) if i have 2 query,in what order are executed?
Thanks anyway for your time and for the speed of response
Re: Problem on set global variable [message #1011035 is a reply to message #1009588] Mon, 18 February 2013 17:47 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Queries are executed when the report runs and only if they are bound to an item that is getting created. If you have two queries, they execute before the creation of the items that uses the respective queries created, but other than that you can not guarantee the order because it can be changed on things like aggregation. Generally if you want to hook something like onFetch it is often better to just hook the onCreate of the table row that uses it.

Jason
Re: Problem on set global variable [message #1011825 is a reply to message #1011035] Wed, 20 February 2013 10:17 Go to previous messageGo to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Hi Jason,
i have another question about run query, if i have 1 query and 2 tables and if i bind the query in both tables, how many times the query is executed?
Thanks
Re: Problem on set global variable [message #1012131 is a reply to message #1011825] Wed, 20 February 2013 23:47 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Great question. By default the query will only execute once. If you are using BIRT 4.2 or later you can change this behavior.
See:
http://www.eclipse.org/birt/phoenix/project/notable4.2.php#jump_11

Jason
Re: Problem on set global variable [message #1061594 is a reply to message #1009218] Mon, 03 June 2013 08:14 Go to previous messageGo to next message
Sandeep Nambiar is currently offline Sandeep NambiarFriend
Messages: 1
Registered: June 2013
Junior Member
Hi,


I am setting a global variable value in onFetch of a dataset.

var test = row["product_count"];

if(test == null){
reportContext.setPersistentGlobalVariable("NewVariableElement","is null");
}
else{
reportContext.setPersistentGlobalVariable("NewVariableElement",test);
}


But When I tried to read the variable from beforeFactory i am getting null.
var tstvalue = reportContext.getPersistentGlobalVariable("NewVariableElement");

If i place the variable some where in the report i will get proper value.
I am using this variable value to do a check for dropping a table.

Please help me to solve this issue..


Thanks in advance
Sandeep
Re: Problem on set global variable [message #1062488 is a reply to message #1061594] Sat, 08 June 2013 05:18 Go to previous message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

The dataSet will not have ran yet. This is why the value is not showing properly in the beforeFactory. You could use the data engine to run the dataSet to check the value you're wanting in the beforeFactory, otherwise, you could just hide the table rather than drop it.

BIRT Exchange DevShare - Data Engine API Example


Michael

Developer Evangelist, Silanis
Previous Topic:Treemap based vizualisation ?
Next Topic:Dynamic Master page
Goto Forum:
  


Current Time: Wed Apr 24 19:42:02 GMT 2024

Powered by FUDForum. Page generated in 0.03296 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top