Jaspersoft BI Tools

iReport,Jaspersoft Design Studio,Jaspersoft Server, Schema Workbench,Analysis,Dashboards, Self Service BI, Domains,Topics,Ad-Hoc Reports, Jaspersoft ETL, Embedding BI,HTML-5 charts, Fusion Charts,JFree Charts,Drill down reports , Drill down Dashboards,Visualize.js, Performance Tuning, D3 Charts, Jaspersoft Customization

Monday, May 06, 2013

Giving Hyperlink to a text field, Row banding in iReport

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.

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

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

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.



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.

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.
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)

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


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:


 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.


:) :)
Thanks for your time to read this tutorial :) :) :)
for any queries :  sadakar.1988@gmail.com