Using global variables in report scripting [message #158276] |
Thu, 04 May 2006 11:31  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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 ?
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.06561 seconds