Skip to main content



      Home
Home » Archived » BIRT » Using global variables in report scripting
Using global variables in report scripting [message #158276] Thu, 04 May 2006 11:31 Go to next message
Eclipse UserFriend
Originally posted by: jaymzs.hotmail.com

Hi,

I'm trying to use global variables in a report and I don't seem to be
having any luck. I tried to follow the examples but I'm clearly doing
something wrong and I'm not sure what.

What I'm trying to do is create a hashmap of this things I want on
startup, from the parameters.
In the initialize event of the report:


importPackage(Packages.java.util);
configMap = new HashMap();
configMap.put("Queries" ,params["Queries"]);
configMap.put("Interval",params["Interval"]);
reportContext.setPersistentGlobalVariable("configMap", configMap);

Then in the open even on my scripted data source:

MultiTypeTTSQueryClass = new Packages.MyQuery();
returnvals = MyQueryClass.doQuery(params["Queries"],params["Interval"]);

configMap = reportContext.getPersistentGlobalVariable("configMap");

num_of_cols = MyQueryClass.getNumOfTypes(params["Queries"]);
type_names = MyQueryClass.parseTypes(params["Queries"]); // returns array
configMap.put("NumOfCols", num_of_cols);
configMap.put("TypeNames", type_names);

totalrows = returnvals.size();
currentrow = 0;

Then in beforeGeneration( chart, context ) of my chart:

seriesCount = 0;
legendCount = 0;
configMap = reportContext.getPersistentGlobalVariable("configMap");
ccolnames = configMap.get("TypeNames");


I then try to access the NumOfCols in my configMap hashmap
in beforeDrawLegendEntry(label,context)
As a test:

label.getCaption().setValue(configMap.get["NumOfCols"]);

and it doesn't seem to work. Anyone know what I'm doing wrong?
Re: Using global variables in report scripting (correction) [message #158292 is a reply to message #158276] Thu, 04 May 2006 11:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jaymzs.hotmail.com

Erm correction:

Hi,

I'm trying to use global variables in a report and I don't seem to be
having any luck. I tried to follow the examples but I'm clearly doing
something wrong and I'm not sure what.

What I'm trying to do is create a hashmap of this things I want on
startup, from the parameters.
In the initialize event of the report:


importPackage(Packages.java.util);
configMap = new HashMap();
configMap.put("Queries" ,params["Queries"]);
configMap.put("Interval",params["Interval"]);
reportContext.setPersistentGlobalVariable("configMap", configMap);

Then in the open even on my scripted data source:

MyQueryClass = new Packages.MyQuery();
returnvals = MyQueryClass.doQuery(params["Queries"],params["Interval"]);

configMap = reportContext.getPersistentGlobalVariable("configMap");

num_of_cols = MyQueryClass.getNumOfTypes(params["Queries"]);
type_names = MyQueryClass.parseTypes(params["Queries"]); // returns array
configMap.put("NumOfCols", num_of_cols);
configMap.put("TypeNames", type_names);

totalrows = returnvals.size();
currentrow = 0;

Then in beforeGeneration( chart, context ) of my chart:

seriesCount = 0;
legendCount = 0;
configMap = reportContext.getPersistentGlobalVariable("configMap");
ccolnames = configMap.get("TypeNames");


I then try to access the NumOfCols in my configMap hashmap
in beforeDrawLegendEntry(label,context)
As a test:

label.getCaption().setValue(configMap.get["NumOfCols"]); and it doesn't
seem to work. Anyone know what I'm doing wrong?

..Do I even need to use persistant variables ?
Re: Using global variables in report scripting (correction) [message #158350 is a reply to message #158292] Thu, 04 May 2006 14:24 Go to previous message
Eclipse UserFriend
What error are you getting?
If you use your scripted ds in a table do you get any results?

What does this return?
configMap = reportContext.getPersistentGlobalVariable("configMap");

num_of_cols = MyQueryClass.getNumOfTypes(params["Queries"]);
type_names = MyQueryClass.parseTypes(params["Queries"]); // returns array

Jason

"js" <jaymzs@hotmail.com> wrote in message
news:1884ed118d79254eb90d068d593016cd$1@www.eclipse.org...
> Erm correction:
>
> Hi,
>
> I'm trying to use global variables in a report and I don't seem to be
> having any luck. I tried to follow the examples but I'm clearly doing
> something wrong and I'm not sure what.
>
> What I'm trying to do is create a hashmap of this things I want on
> startup, from the parameters.
> In the initialize event of the report:
>
>
> importPackage(Packages.java.util);
> configMap = new HashMap();
> configMap.put("Queries" ,params["Queries"]);
> configMap.put("Interval",params["Interval"]);
> reportContext.setPersistentGlobalVariable("configMap", configMap);
>
> Then in the open even on my scripted data source:
>
> MyQueryClass = new Packages.MyQuery();
> returnvals = MyQueryClass.doQuery(params["Queries"],params["Interval"]);
>
> configMap = reportContext.getPersistentGlobalVariable("configMap");
>
> num_of_cols = MyQueryClass.getNumOfTypes(params["Queries"]);
> type_names = MyQueryClass.parseTypes(params["Queries"]); // returns array
> configMap.put("NumOfCols", num_of_cols);
> configMap.put("TypeNames", type_names);
>
> totalrows = returnvals.size();
> currentrow = 0;
>
> Then in beforeGeneration( chart, context ) of my chart:
>
> seriesCount = 0;
> legendCount = 0;
> configMap = reportContext.getPersistentGlobalVariable("configMap");
> ccolnames = configMap.get("TypeNames");
>
>
> I then try to access the NumOfCols in my configMap hashmap
> in beforeDrawLegendEntry(label,context)
> As a test:
>
> label.getCaption().setValue(configMap.get["NumOfCols"]); and it doesn't
> seem to work. Anyone know what I'm doing wrong?
>
> .Do I even need to use persistant variables ?
>
>
>
Previous Topic:removing date at bottom of tables
Next Topic:Chart API: Scatter Series: Holes in sparse y-series
Goto Forum:
  


Current Time: Wed May 28 23:19:14 EDT 2025

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

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

Back to the top