JHyperLink can be used to create hyperlinks in page reports. This section shows you two specific examples about using JHyperLink:
Sometimes you have a number of reports that contain different views of the same data. You may want to build a summary report to organize these reports together. For example, Report A is Summary Information for Orders, while Report B is an Invoice Report showing the detail line items of the order. When you click on the Order ID in Report A, it will go to the detail page of that order in Report B. With this hyperlink feature, you can build hyperlinks among reports. In addition, you can also insert any hyperlink to be invoked. In any case, a web browser will be displayed to view the specified pages.
Two hyperlinks have been successfully built into the report.
Notes: After you insert a JHyperLink into a report which is to be exported to PDF, Excel or HTML, you can specify whether to make the hyperlink effective by setting a property which corresponds to the format type. Respectively, they are: Enable Hyperlink in PDF for PDF, Enable Hyperlink in Excel for Excel and Enable Hyperlink in HTML for HTML.
JHyperLink can be used to link reports similar to master and detail reports to show related information, such as Order detail to higher level Year to Date Sales. You can use the JHyperLink object to control the URL to show the information in the linked reports on JReport Server. It is similar to master/detail but does not have the ability to navigate through the detail and return to the master. The key to using JHyperlink is learning how to use URLs to call page reports. For additional information, see Running reports via URL in the JReport Server User's Guide.
For how to use JHyperLink to link reports using a URL, JReport Designer provides an example for your better understanding.
All the needed materials for this example, including the reports and catalog are in <install_root>\help\samples\UDODemo
.
<install_root>\help\samples\UDODemo\reports
.Linking the master report to the detail report
Formulas will be used to control the property values URL and Display Value of JHyperLink to make it link the master and detail reports.
A JHyperLink is inserted in the Detail panel of the report. The URL and Display Value property values of the UDO are as follows:
"http://localhost:8888/jrserver?jrs.cmd=jrs.web_vw&jrs.catalog=/USERFOLDERPATH/admin/Demo.cat&jrs.report=/USERFOLDERPATH/admin/SalesPerformancebyYear.cls&jrs.result_type=8&jrs.param$pEmployeeID="+@"Employee_Employee ID"
This URL value enables you to drill down to the detail report and also make a link for this detail report on the top of the page for you to drill up and down.
In the GroupHeader panel, the value of Total is a JHyperLink, whose property values URL and Display Value are both controlled by formulas.
"http://localhost:8888/jrserver?jrs.cmd=jrs.web_vw&jrs.catalog=/USERFOLDERPATH/admin/Demo.cat&jrs.report=/USERFOLDERPATH/admin/SalesYearPerformancebyQuarter.cls&jrs.result_type=8&jrs.param$pEmployeeID="+@"Employee_Employee ID"+"&jrs.param$pYear="+@getYear;
Where, the URL is used to access the detail report SalesYearPerformancebyQuarter.cls, and the records of the detail report are filtered by the parameters pEmployeeID and pYear.
"$"+ToText(@Sum_TotalSales0)
This formula returns the total sales amount for the year.
Running the reports on JReport Server
This example requires you to access the report by URL, you can drill down through the reports. To do this:
Note: When using JHyperLink to link reports as master and detail reports, if a parameter with its value containing special characters such as "\" and "&" is used in the URL, you need to add "\" before the special character. For example, if the parameter value is a&b, you need to enter it as a\&b.