Simple hyperlink to text field in the same report (works in iReport; not in JasperServer)

I have a very simple working report, see attachment. It is based on the Sample database provided with iReport and JasperReports Server.

What I want: I want to have a hyperlink to a text field element in the same report.
In the sample report provided, click on the "Link to summary" and one should jump to the Summary text field.

In iReport this works fine in the Internal Preview, in PDF, in HTML. All works fine.

When imported into the JasperServer,  I get a gray empty page. So in JasperServer this is not working.
See the first image added. The second image shows the hyperlink address in JasperServer when I hoover with the mouse over de link.

Since I'm referring to a location in the same document, I used as Hperlink target: Self and Hyperlink type: LocalAnchor

I'm using iReport 4.0.2 and JasperReports Server CP 4.1.0.

I need a way that works both in iReport and JasperServer.

Post Edited by mulcamd at 09/13/2011 18:31
mulcamd's picture
Joined: Mar 16 2011 - 11:47am
Last seen: 2 years 11 months ago

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


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 :

naveen.sharma - 9 years 1 month ago
The same link double HyperLink reference given to different reports?
destek - 8 years 1 month ago
show 2 more...

it is not work in jaspersoft designer 5.6.0

khushal.solanki8 - 6 years 2 weeks ago


I have one query.

I have main report and sub report A in the same main report.

I have a scenerio where clicking on the text field in one sub reports(subreport A) should  open another sub report(sub report B) .

Could any one help me on this?

Thanks in Advance.

kiranmaisep6th - 5 years 6 months ago

0 Answers:

No answers yet