Jump to content
We've recently updated our Privacy Statement, available here ×

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


mulcamd

Recommended Posts

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
Link to comment
Share on other sites

  • 2 years later...
  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

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.

http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink-300x168.png

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

http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink2-300x156.png

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

http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink3-300x79.png

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.

 http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink4-300x76.png

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.

http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink5-300x143.png

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.

http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink6-300x49.png

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)

 http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink8-300x53.png

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

http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink9-300x220.png

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:

http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink10-300x44.png

 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.

http://helicaltech.com/blogs/wp-content/uploads/2013/05/Hyperlink9-300x220.png

<em>:)</em> <em>:)</em>
Thanks for your time to read this tutorial <em>:)</em> <em>:)</em> <em>:)</em>
for any queries :

Link to comment
Share on other sites

  • 11 months later...
  • 2 years later...
  • 6 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...