Built-in UDOs: JHyperLink and JRotator
Logi JReport provides two built-in UDOs: JHyperLink and JRotator. JHyperLink is used to create hyperlinks in reports, and JRotator to rotate text or images.
Below is a list of the sections covered in this topic:
Creating Links with JHyperLink
JHyperLink can be used to create hyperlinks in page reports that are created using query resources. The following shows two specific examples about using JHyperLink.
Example 1: Building Hyperlinks 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 select 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.
- Start Logi JReport Designer and open the report in which you want to build a hyperlink.
- Select Insert > UDO to display the Insert UDO dialog.
- Select JHyperLink from the UDO drop-down list, and then select OK. You will then be able to insert a hyperlink into the report.
- Keep the JHyperLink focused, and then go to the Report Inspector.
- Input http://localhost:8888 in the value cell of the URL property as the Logi JReport Server address, make sure the Executer Class Name value is jet.udos.IEExecuter, and then type Logi JReportServer in the Display Value property value cell as the display name of the hyperlink.
- Insert another hyperlink using the same way and define its properties in the Report Inspector as follows:
- URL: http://www.jinfonet.com
- Executer Class Name: jet.udos.IEExecuter (the default value)
- Display Value: Website
Two hyperlinks have been successfully built into the report.
- In view mode, select the Logi JReportServer hyperlink that you just made. It will bring out a browser session to connect with Logi JReport Server. Make sure that you have launched Logi JReport Server and that the URL corresponds with your server configuration.
- Select the Website hyperlink. You will then see the http://www.jinfonet.com home page in a web browser.
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.
Example 2: Linking Reports Using Parameters with JHyperLink
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 Logi 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 in the Logi JReport Server User's Guide.
An example is provided for your better understanding about how to use JHyperLink to link reports using a URL. All the needed materials for this example, including the reports and catalog are in <install_root>\help\samples\UDODemo
.
- In Logi JReport Designer, open the catalog for this example Demo.cat in
<install_root>\help\samples\UDODemo\reports
. - Select one of the existing reports and ensure the reports in this catalog can run. If there is a problem, open the Catalog Manager, highlight the connection node, then in the Properties sheet, modify the value of the URL property to connect to the demo database, which is jdbc:hsqldb:<install_root>\help\samples\UDODemo\db\demo.
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.
- Open the report that contains the master report - mainreport.cls.
A JHyperLink is inserted in the Detail panel of the report. The URL and Display Value property values of the UDO are as follows:
- URL: Controlled by the formula linkToSalesYearly, which is defined 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.
- Display Value: Determined by the DBField EmployeeName to show the Employee Name in the master report.
- URL: Controlled by the formula linkToSalesYearly, which is defined as follows:
- Open the report that contains the detail report SalesPerformancebyYear.cls.
In the Group Header panel, the value of Total is a JHyperLink, whose property values URL and Display Value are both controlled by formulas.
- URL: Controlled by the formula linkToQuarter, which is defined as follows:
"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.
- Display Value: Controlled by the formula getSalesByYear, which is defined as follows:
"$"+ToText(@Sum_TotalSales0)
This formula returns the total sales amount for the year.
- Target: The options are self, parent, top and blank. Use self to replace the current report with the linked report. Use blank if you want to open a new browser tab so you can return to the master report window.
- URL: Controlled by the formula linkToQuarter, which is defined as follows:
Running the reports on Logi JReport Server
This example requires you to access the report by URL. You can drill down through the reports.
- Start Logi JReport Server.
- Publish the reports and catalog to Logi JReport Server as admin into the root level of My Reports.
- Run the master report mainreport.cls in Page Report Studio.
- Select any name in the Employee Name column, and the year's performance of the employee will be displayed.
- Select the Total number, and it will drill down to the next detail report.
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".
Rotating Text/Image with JRotator
JRotator is used to rotate text or images. Since Logi JReport currently supports rotating only images but not text, using JRotator to achieve text rotation becomes a feasible solution. JRotator rotates the text inside the JRotator object but not the object itself so if you rotate text or DBFields you may have to change the size of the container in order to see the full value.
The following introduces three cases of using JRotator:
Using JRotator to Rotate Text
- Start Logi JReport Designer and open the report in which you want to insert some rotated text.
- Select Insert > UDO to display the Insert UDO dialog.
- Select JRotator from the UDO drop-down list, and then select OK.
- Keep the JRotator focused and go to the Report Inspector.
- Locate the Display Value property and type in the required text in the value cell, then select outside of the cell. You will then see the typed text displayed in the JRotator.
- Specify a rotation degree in the value cell of the Rotate property, for example, 180, then select outside of the cell. You will then find the text in the JRotator upside down.
- Save the report.
Using JRotator to Rotate an Image
- Start Logi JReport Designer and open the report in which you want to insert a rotated image.
- Select Insert > UDO.
- In the Insert UDO dialog, select JRotator from the drop-down list, and then select OK.
- Keep the JRotator focused and go to the Report Inspector.
- Specify the local path of the required image in the value cell of the Display Image property, for example, C:\image.jpg, then select outside of the cell. You will then see the image displayed in the JRotator.
- Specify a rotation degree in the value cell of the Rotate property, for example, 45, then select outside of the cell. You will then find the image in the JRotator at a 45 degree angle.
- Resize the JRotator container as needed to view the entire image.
- Save the report.
Using JRotator to Rotate a DBField
- Start Logi JReport Designer and open the report in which you want to insert a rotated DBField.
- Select Insert > UDO.
- In the Insert UDO dialog, select JRotator from the drop-down list, and then select OK.
- Keep the JRotator focused and go to the Report Inspector.
- In the Display Value value cell, select the required DBField or create a formula for a calculated field and select the formula from the dropdown list. Then select outside of the cell and you will see the DBField displayed in the JRotator.
- Specify a rotation degree in the Rotate value cell, for example, 90, then select outside of the value cell. You will then find the DBField in the JRotator at a 90 degree angle.
- Change the size of the JRotator container as needed to view the entire text.
- Save the report.