Skip to main content



      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 10:13 Go to next message
Eclipse UserFriend
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 12:33 Go to previous messageGo to next message
Eclipse UserFriend
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 05:55 Go to previous messageGo to next message
Eclipse UserFriend
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 12:47 Go to previous messageGo to next message
Eclipse UserFriend
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 05:17 Go to previous messageGo to next message
Eclipse UserFriend
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 18:47 Go to previous messageGo to next message
Eclipse UserFriend
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 04:14 Go to previous messageGo to next message
Eclipse UserFriend
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 01:18 Go to previous message
Eclipse UserFriend
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
Previous Topic:Treemap based vizualisation ?
Next Topic:Dynamic Master page
Goto Forum:
  


Current Time: Wed Mar 19 09:32:28 EDT 2025

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

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

Back to the top