By: Tim Dalsing - tdalsing
Parameters for attribute values
2003-11-18 19:10
Does anyone know of a way of passing a parameter or variable value for an attribute value in a report? For example:
<reportElement x="0" y="${myparam}" .../>
The value of the attribute must be a NMTOKEN, which it isn't, so the parser barfs.
Any help would be appreciated.
Tim.
By: Tobias Karlsson - tullabeah
RE: Parameters for attribute values
2003-11-19 05:03
Hi Tim!
I solved this by loading the XML-template into my javacode. I can try to describe how I did this:
I used a JasperDesign object by JRXmlLoader.load(InputStream in).
From the JasperDesign I can get a JRDesignBand and from the band I can get the elements. Once I got the elements I can pick my specific element by the KEY-attribute witch I?ve set in the XML-template (<reportElement x="0"... Key="MyKey1">).
When I have the element I can call for JRDesignElement.setY().
Then you send the design to JasperCompileManager.
This would do the same thing as you describe.
Also it might be a good thing to review the NoXMLDesign in the Jasper demo/samples.
Good luck
By: Tim Dalsing - tdalsing
RE: Parameters for attribute values
2003-11-19 06:26
Tobias,
Thanks for the info. I had considered dynamically generated the XML template, but I was worried about performance. The report compiler takes fairly long to compile the XML into the report object.
Have you noticed any performance problems with this strategy?
I haven't looked into the NoXMLDesign demo, so I will check that out next. Have you tried it?
Tim.
By: Tobias Karlsson - tullabeah
RE: Parameters for attribute values
2003-11-21 02:37
Hi Tim!
I think the performance is just about the same as if you have a XML-template to compile into a report.
The report needs to be recompiled after each change, and that may slow thing down a bit.
No, I haven?t noticed any specifik loss in performance, but then I havn?t really been looking for optimal performace in matter of speed.
Yes, I did look at NoXmlDesign demo, but in order to minimize the amount of code I need to write for a report, I desided to write the base design in XML and then make my specific changes as I descibed above.
Jasper is great for straightforward reports, and a little bit more complex when you need to make it dynamic, but so far we?ve managed to find our ways around.
T.
Parameters for attribute values
2003-11-18 19:10
Does anyone know of a way of passing a parameter or variable value for an attribute value in a report? For example:
<reportElement x="0" y="${myparam}" .../>
The value of the attribute must be a NMTOKEN, which it isn't, so the parser barfs.
Any help would be appreciated.
Tim.
By: Tobias Karlsson - tullabeah
RE: Parameters for attribute values
2003-11-19 05:03
Hi Tim!
I solved this by loading the XML-template into my javacode. I can try to describe how I did this:
I used a JasperDesign object by JRXmlLoader.load(InputStream in).
From the JasperDesign I can get a JRDesignBand and from the band I can get the elements. Once I got the elements I can pick my specific element by the KEY-attribute witch I?ve set in the XML-template (<reportElement x="0"... Key="MyKey1">).
When I have the element I can call for JRDesignElement.setY().
Then you send the design to JasperCompileManager.
This would do the same thing as you describe.
Also it might be a good thing to review the NoXMLDesign in the Jasper demo/samples.
Good luck
By: Tim Dalsing - tdalsing
RE: Parameters for attribute values
2003-11-19 06:26
Tobias,
Thanks for the info. I had considered dynamically generated the XML template, but I was worried about performance. The report compiler takes fairly long to compile the XML into the report object.
Have you noticed any performance problems with this strategy?
I haven't looked into the NoXMLDesign demo, so I will check that out next. Have you tried it?
Tim.
By: Tobias Karlsson - tullabeah
RE: Parameters for attribute values
2003-11-21 02:37
Hi Tim!
I think the performance is just about the same as if you have a XML-template to compile into a report.
The report needs to be recompiled after each change, and that may slow thing down a bit.
No, I haven?t noticed any specifik loss in performance, but then I havn?t really been looking for optimal performace in matter of speed.
Yes, I did look at NoXmlDesign demo, but in order to minimize the amount of code I need to write for a report, I desided to write the base design in XML and then make my specific changes as I descibed above.
Jasper is great for straightforward reports, and a little bit more complex when you need to make it dynamic, but so far we?ve managed to find our ways around.
T.
0 Answers:
No answers yet