Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Paging in table's and charts not getting displayed on HTMLRenderOption
pawasarmol
Hello All
I am a newbie to BIRT and just started exploring it from last 2-3 days. I am facing couple of issues and would really appreciate any help.
Right now I am having 2 issues
1) I want to implement pagination on my report.
When I view the report in Web Viewer it shows the pagination and other options properly.
Now what I am trying to do is, invoke my report from a Java/JSP code. For that I followed examples on web regarding how to integrate BIRT with Tomcat. And which worked fine.
But I am not sure how will I achieve pagination using my Java code.
I am using a table , and have simple select query associated with it which is returning me 500+ records. Now I want to display this in my report using HTML render and have pagination implemented for it. (having the table displayed same as display table will be the best option)
And the second issue is
2) I am not able to see my Pie chart on HTML render. I am able to see the Pie chart properly when I use PDF render from my java code but not from HTML render. I tried suggestion given in previous post regarding
options.setSupportedImageFormats( "PNG;GIF;JPG;BMP;SWF");
but that did not help.
I am using BIRT 2.6.1 and my PIE chart format is SVG. ( I also tried chaining it to other format but didn?t worked either)
And as I earlier said I am a newbie to BIRT , any comments regarding how should I go about learning BIRT would be greatly appreciated, as I feel a bit lost.
Thanks
Find more posts tagged with
Comments
mwilliams
Hi pawasarmol,
Straight HTML output is not paginated. If you can call a URL from your code, you can just call the web viewer. A good place to learn about BIRT is here on BIRT-Exchange by checking out the Getting Started Guide in the Wiki, browsing the devShare and forums for posts about what you're wanting to do, and just asking questions.
http://www.birt-exchange.org/org/wiki/index.php?title=Main_Page
pawasarmol
Thanks for the response <br />
<br />
I did read somewhere that IRenderTask can be used for paging , with methods such setPageNumber ,setPageRange. And also IPageHandler , Although didn't understood exactly how to use those and would those be applicable for HTML render.<br />
<br />
And also if you see my question, I had one more question regarding Pie chart not getting rendered properly on HTML view. Any input on it would be of great help. <br />
Thanks<br />
<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="71551" data-time="1292886593" data-date="20 December 2010 - 04:09 PM"><p>
Hi pawasarmol,<br />
<br />
Straight HTML output is not paginated. If you can call a URL from your code, you can just call the web viewer. A good place to learn about BIRT is here on BIRT-Exchange by checking out the Getting Started Guide in the Wiki, browsing the devShare and forums for posts about what you're wanting to do, and just asking questions.<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/wiki/index.php?title=Main_Page'>http://www.birt-exchange.org/org/wiki/index.php?title=Main_Page</a><br
/></p></blockquote>
mwilliams
The viewer is built using the API's. You could download the source code and see what was done for the viewer to create paging.
As for the charts, I have not seen this issue before. I'll look around and see if I see anything. I'll post in here if I do.
pawasarmol
Thanks a lot for all the information. <br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="71603" data-time="1292969283" data-date="21 December 2010 - 03:08 PM"><p>
The viewer is built using the API's. You could download the source code and see what was done for the viewer to create paging.<br />
<br />
As for the charts, I have not seen this issue before. I'll look around and see if I see anything. I'll post in here if I do.<br /></p></blockquote>
pJune
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="71603" data-time="1292969283" data-date="21 December 2010 - 03:08 PM"><p>
The viewer is built using the API's. You could download the source code and see what was done for the viewer to create paging.<br />
<br />
As for the charts, I have not seen this issue before. I'll look around and see if I see anything. I'll post in here if I do.<br /></p></blockquote>
<br />
I have the same issue with the chart not being displayed. Did you find the answer to this?
Yaytay
<blockquote class='ipsBlockquote' data-author="'pawasarmol'" data-cid="71546" data-time="1292870319" data-date="20 December 2010 - 11:38 AM"><p>
2) I am not able to see my Pie chart on HTML render. I am able to see the Pie chart properly when I use PDF render from my java code but not from HTML render. I tried suggestion given in previous post regarding <br /></p></blockquote>
<br />
Am I right in thinking that you are using your own web server/service (hosted in tomcat) using the BIRT report engine?<br />
If you are then you will have to jump through some extra hoops to get charts working in HTML output.<br />
<br />
With the other output formats charts are presented inline, the output from BIRT is a single complete document with everything in it.<br />
For HTML this is not the case, the charts have to be written to disc somewhere, the HTML has to have a generated URL written to it, and then when that URL is requested your service has to supply the generated file.<br />
<br />
So there are three things you need to do:<br />
<ul class='bbc'><li>Tell BIRT where to save the file.<br />
To do this you can either use the provided HTMLImageHandler or write your own, and then tell BIRT to use it like this: options.setImageHandler(new HTMLServerImageHandler());</li><li>Tell BIRT the leading part of the URL to use.<br />
This is done using: htmlOptions.setBaseImageURL("<a class='bbc_url' href='
http://myhost/prependme?image='>http://myhost/prependme?image="</a>);</li><li>Serve
the file in response to a request on the generated URL.<br />
You're on your own for this last one
</li></ul>
<br />
There's a brief example of this here: <a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php#irendertask'>http://www.eclipse.org/birt/phoenix/deploy/reportEngineAPI.php#irendertask</a><br
/>
<br />
Note that all this only applies if your HTML client is interacting with YOUR code, if it's interacting with BIRT's own server then it's handled for you.<br />
If this does apply to you and you'd like more help then let me know.<br />
<br />
Whatever you are doing you can look at the HTML and see what URL it is using for the chart image, that might give you some pointers to the problem.
pJune
Thanks for your answer. I have a standalone java application. I display the report using JEditorPane, and everything works fine except for the chart that it is not being displayed. This is what I am doing:
IReportDocument iReportDocument = engine.openReportDocument("/resources/testingChartReport.rptdocument");
IRenderTask renderTask = engine.createRenderTask(iReportDocument);
renderTask.getAppContext().put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, ChartReport.class.getClassLoader());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
IRenderOption options = new RenderOption();
options.setOutputFormat("html");
HTMLRenderOption htmlOptions = new HTMLRenderOption(options);
HTMLCompleteImageHandler htmlImageHandler = new HTMLCompleteImageHandler();
htmlOptions.setImageHandler(htmlImageHandler);
htmlOptions.setImageDirectory("/resources/image");
htmlOptions.setEmbeddable(true);
htmlOptions.setOutputStream(bos);
renderTask.setRenderOption(htmlOptions);
renderTask.setPageRange("1-2");
renderTask.render();
iReportDocument.close();
reportEditorPane.setContentType("text/html");
reportEditorPane.setText(bos.toString());
When I do a system print out, this is what I get for the chart:
<div class="style_3" id="__bookmark_2" style=" width: 7.052in; height: 4.958in;"></div>
Everything gets displayed but the chart. I don't know what I am doing wrong. I appreciate any comments. Thanks in advanced.
Yaytay
I just wrote this as a test:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
@Test
public void testRunReport() throws BirtException, IOException {
IReportEngine reportEngine = createReportEngine();
String filename = "C:\\Temp\\birt-source-3_7_1\\plugins\\org.eclipse.birt.report.designer.samplereports\\samplereports\\Reporting Feature Examples\\Combination Chart\\CustomerOrdersFinal.rptdesign";
InputStream resourceStream = openFileStream( filename );
assertNotNull( resourceStream );
try {
IReportRunnable reportRunnable = reportEngine.openReportDesign( resourceStream );
assertNotNull(reportRunnable);
File tempDoc = createTempFile( baseFilename( filename ), ".rptdocument");
assertNotNull(tempDoc);
try {
IRunTask reportRunTask = reportEngine.createRunTask( reportRunnable );
assertNotNull(reportRunTask);
try {
reportRunTask.setParameterValue("customer", 103);
reportRunTask.setParameterValue("order", 10123);
startTime = System.currentTimeMillis();
IReportDocument reportDocument = runReport(reportEngine, reportRunTask, tempDoc);
runTime = System.currentTimeMillis();
IRenderTask renderTask = reportEngine.createRenderTask( reportDocument );
assertNotNull(renderTask);
try {
File tempOutput = new File("C:\\Temp\\Output.html");
System.err.println( tempOutput );
FileOutputStream outputStream = new FileOutputStream( tempOutput );
assertNotNull(outputStream);
try {
IRenderOption options = new RenderOption();
options.setOutputFormat("html");
HTMLRenderOption htmlOptions = new HTMLRenderOption(options);
HTMLCompleteImageHandler htmlImageHandler = new HTMLCompleteImageHandler();
htmlOptions.setImageHandler(htmlImageHandler);
htmlOptions.setImageDirectory("/resources/image");
htmlOptions.setEmbeddable(true);
htmlOptions.setOutputStream(outputStream);
renderTask.setRenderOption(htmlOptions);
renderTask.setPageRange("1-2");
renderTask.render();
renderTime = System.currentTimeMillis();
assertEquals(0, renderTask.getErrors().size());
} finally {
outputStream.close();
}
} finally {
renderTask.close();
}
} finally {
reportRunTask.close();
}
} finally {
tempDoc.delete();
}
} finally {
resourceStream.close();
}
}
</pre>
<br />
And it produces an HTML document with an SVG image for the chart.<br />
The HTML for the image comes out as:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<div>
<embed id="__bookmark_1" onresize="document.getElementById('__bookmark_1').reload()" type="image/svg+xml" src="file:/C:/Work/spudsoft-birt-excel-emitters/SpudSoft BIRT Excel Emitters Tests/./resources/image/custom1.svg" alt="" style=" width: 440.208pt; height: 279.72pt;display: block;"></embed>
</div>
</pre>
Note that it put the image in a location relative to the source, not necessarily somewhere useful (in my live application I override the image handler to control where it locates the files).<br />
<br />
So, a few things to try:<br />
<ul class='bbc'><li>Is there a problem with the format of the image that you have chosen? The sample report used SVG, so give that a go.</li><li>Can you get the same output as me using the same report (download the BIRT source to get them)?</li><li>Are you able to post your report for me to try? Or can you reproduce the problem with a simpler one that uses either a scripted dataset or the sample data source?</li><li>If you write your own HTML image handler, just derive from the normal one and override every method to log some output, then you will be able to see whether the image handler is actually being called (and where it has put the image).</li></ul>
pJune
Hi, I tried your code which is really similar to mine and it worked. I created a report with the BIRT sample database and I think that was the reason for the report to work. My reports are created using a custom ODA data source driver and data set. When I run the code for my report, it does not work. I am guessing now that I need to implement some method inside my oda drivers, but I have no idea where or what I have to do. Do you have any other theory of why the code is working with the report created with the birt sample database and not working with my reports?
Thank you very much for taking the time on answering my questions.
pJune
<blockquote class='ipsBlockquote' data-author="'pJune'" data-cid="94855" data-time="1328119745" data-date="01 February 2012 - 11:09 AM"><p>
Hi, I tried your code which is really similar to mine and it worked. I created a report with the BIRT sample database and I think that was the reason for the report to work. My reports are created using a custom ODA data source driver and data set. When I run the code for my report, it does not work. I am guessing now that I need to implement some method inside my oda drivers, but I have no idea where or what I have to do. Do you have any other theory of why the code is working with the report created with the birt sample database and not working with my reports?<br />
Thank you very much for taking the time on answering my questions.<br /></p></blockquote>
<br />
I got it to work! It was stupid. Turns out I was missing a lot of jars that have to do with charts. Thanks for your help.
Yaytay
<blockquote class='ipsBlockquote' data-author="'pJune'" data-cid="94865" data-time="1328131370" data-date="01 February 2012 - 02:22 PM"><p>
I got it to work! It was stupid. Turns out I was missing a lot of jars that have to do with charts. Thanks for your help.<br /></p></blockquote>
Excellent.<br />
<br />
I couldn't see how a different data source would break charting
<br />
<br />
Jim