Sometimes simple things might take lots of time….

Here is the tutorial …..
I’m using the following versions : iReport-Pro .5.0, Japserserver CE, Database : foodmart database in postgre SQL.
I’m using two reports
i) hyperlink
ii)hyperlink_second
I’m gonna show how we can give hyperlink in one report and how we will navigate to another report.
And How to give row banding in iReport?

In Report 1:
Step 1: Connect to database (Click on database icon and give all the details and test it )
Step 2: delete all the not needed bands(If we don’t delete it leads to page gaps in the output)
Step 3: Write a simple query in Report Query area ( Just right click on report name in the
Report Inspector then Select the query)
I’ve given like this : select 1 as One
Step 4: The bands I’m interested to take are : Column header and Detail bands respectively.
Step 5: Drag and drop the field to detail area And drag and drop a text field from palette to
column header.
The below image gives somehow idea.

Hyperlink to text field and Rowbanding for fields

Step 6: Giving Hyperlink to text field
i) Write text in double quotes like : “Hyper link”.( Text field should take double quotes whereas static text field doesn’t take double quotes and doesn’t applicable to create hyperlink)
ii) Right Click on the text field ->Click on Hyperlink-> It opens a window
see the sample in the following image

Hyperlink2

iii) Give Hyperlink target as : Blank
Hyperlink type as : ReportExecution
iv) Click on Link Parameters.. Give  Link parameter name as : _report
Parameter Class Name as : java.lang.String
Value Expression : location/Path of the second report in the server
for example the path is : “/reports/Demos_Sadakar/HyperLinkDemo/Hyperlink_Report2”
We can observe the location in the below image

Hyperlink3

NOTE : Remember that Hyperlink_Report2 in the URL is the ID of the jasperReport when we give at the time uploading report to server.. i.e, it is not the name of the Report.

 Hyperlink4

Step 7: Now save the report and upload to the server(Hope we know how to upload a report to server. Please find how to upload a report to server in the list of posts of my blog)

In Report 2:( A normal report with row banding functionality)
Step 1: Create a report and write query in query area
(Give same database details.. foodmart details)
I have taken this query : select * from employee
Step 2: Just drag and drop fields from Fields node of Report Insepector to Detail band.
( dragging only few fields)
Step 3: Now we are working on row banding.
i) Go to Report Inspector panel
ii) Right click on  Style option and Add some style.. I’ve given default name as style1
iii)Right click on style1 and select Add Conditional Style
iv) Now double click on it and i’ll open Expression Editor.. there we need to give the follwoing condition
new Boolean($V{REPORT_COUNT}.intValue() % 2 == 0)
In the above expression $V{REPORT_COUNT} is the default variable provided by jasperians in iReport. Check variables in the Report Insepctor.

Hyperlink5

v) Go to the properties of Conditional Style expression it opens it’s poperties( not click on Style1.. click on the conditional thing). In the properties window select give your favourite BackColor.
I’m showing the scenario in an image.

Hyperlink6

NOTE: do not check Opaque check box. just leave it.

Step 4:  Now select the fields you want to apply for the fields. I’ve selected all the fields that I’ve dragged to the Detail band. You can observe the multiple Objects properties window on the right side.
From the properties go to style and give the style1( just click on it it’ll show all the created styles.. In our example we have created only one style i.e, style1)

 Hyperlink8

That’s it. Now save the report and see the output of the report in the server . It’d look like the following

Hyperlink9

Execution of the Reports using hyperlink- Final Output.
NOTE : When we create an hyperlink and if it works fine then the color of the text changed to light blue and it’ll have underscore on mouseover.

First Report Output:

Hyperlink10

 Now click on “Hyper Link” that we are seeing on..

It’ll redirect to another page which we call it as hyperlink functionality in iReport.

Hyperlink9

🙂 🙂
Thanks for your time to read this tutorial 🙂 🙂 🙂
for any queries :  nikhilesh@helicaltech.com

2 comments

  1. hibernate tutorial

    Heya i am with the major time frame in this article. I stumbled onto that table and I to locate It truly practical & them solved the problem away considerably. I’m hoping to provide something all over again as well as guide people as you helped me.

  2. Davy

    Pathum Herath HI,Thank you very much for your post. It is really ufsuel. Im currently using the trial version of Enterprise Edition of Pentaho BI Server 3.8. I want to filter user sensitive data for my dashboard. I really appreciate if you could give me some clue about that. Please keep up the good workThanks and RegardsPathum

Leave a Reply