Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Introducing BIRT iHub F-Type: Integrating into Applications

DZone's Guide to

Introducing BIRT iHub F-Type: Integrating into Applications

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

Originally Written by Michael Williams

If you’re familiar with open source BIRT and what the out-of-the-box options for integration are, you know that you had the viewer that could be called by URL, the viewer tag library that allowed you to embed the viewer into a JSP page, or a custom solution you built using the BIRT APIs. With BIRT iHub F-Type, you still have the ability to call visualizations by URL, but you also add the JavaScript API (JSAPI) which allows you to easily embed BIRT content into any page that allows for the use of JavaScript.

In this blog, I’ll show a couple quick examples of calling reports by URL and a couple simple examples of using the JavaScript API to embed BIRT content into a web page.

Calling Reports by URL

When the only integration you care about is to be able to link out to a design from your application or webpage, a simple URL will do. If you’re upgrading your open source application to use BIRT iHub F-Type, you can use the same pattern of URL as you did with the open source viewer, so upgrading is relatively painless.

For example:

http://192.168.1.107:8700/iportal/frameset?__report=%2FHome%2Fadministrator%2FSampleReport.rptdesign

If you’re not adapting an open source application your URL would look more like this one:

http://192.168.1.107:8700/iportal/executereport.do?__vp=Default%20Volume&volume=Default%20Volume&__executableName=%2FHome%2Fadministrator%2FSampleReport.rptdesign

runByURL

If you can’t remember the URL pattern, don’t worry. All you need to do is go into the iHub UI, run your design by clicking on it, drop down the menu, and click the “Link to this page” option.

linkToThisPage

The top option in this window is a link to the design. Copy that and use it wherever you need to.

linkToThisPageDialog

There are lots of URL parameters available to customize what you get from your URL. One example of this is adding __format=pdf to the above URL:

http://192.168.1.107:8700/iportal/executereport.do?__vp=Default%20Volume&volume=Default%20Volume&__executableName=%2FHome%2Fadministrator%2FSampleReport.rptdesign&__format=pdf

This will tell the BIRT iHub F-Type to return the PDF copy of the report output.

runByURLpdf

Using the JSAPI

When your goal is to have a more seamless integration of BIRT content into your application, the JavaScript API (JSAPI) is where you’ll want to start. The JSAPI allows you to quickly and easily embed your BIRT content into any page that allows for the use of JavaScript.

To make it even simpler, you don’t even HAVE to know JavaScript to do the simplest case of embedding using the JSAPI. The iHub will give you a bare minimum block of code for embedding the viewer into you application by simply running your report from the iHub by URL or from the console, then going to the menu and clicking on “Link to this page” like described in the URL section, above. However, this time, we’ll use the second option.

jsapiCode

If you copy and paste this into a HTML page, then open it up in the browser, you’ll see the following:

sampleJSAPI

As you can see, the entire viewer is embedded into the page allowing you to step through all 11 pages of the report. There are many settings and features that can be set with the JSAPI to customize your embedded content.

For example, if you bookmarked an item in your report and would like to only embed that single element into your page, you only need to add a single line of script. In the report I used for this blog, I have bookmarked the chart with “myChart”. Inside the myInit function, we simply use the line viewer1.setReportletBookmark(‘myChart’); and we get a single page in the viewer showing just the chart:

sampleJSAPIReportletWithToolbar

Now, what if we don’t want to show the toolbar? To get rid of that, we would just add options.enableToolBar(false); and we’d see just the chart with no toolbar:

sampleJSAPIReportlet

You can find more of the things you can do with the JavaScript API by taking a look at the API reference in the documentation.

The report and sample HTML page used in this blog will be posted in the devShare, soon. I will update the blog with a link when it’s available.

Thanks for reading. If you have any questions or comments, please feel free to use the comments section below or visit the BIRT iHub F-Type forum. You can also find more information about the BIRT iHub F-Type in the deployment guide and documentation.

-Michael

For more blogs in the “Introducing BIRT iHub F-Type” series, see the list below:

 

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

Published at DZone with permission of Michael Singer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}