### Binding links to objects

You can bind links to labels, images, DBFields, formula fields, parameter fields, special fields, and the category (X) axis labels, legend labels, or data markers of charts. The link can either be a simple link or a conditional link. With conditional link, different targets can be loaded based on different conditions. However, conditional link is not supported on independent labels that are not bound with datasets.

To bind a simple link to an object:

1. Right-click the object and click Link on the shortcut menu to display the Insert Link dialog.
2. From the Link Type drop-down list, select the target to which the object will be linked: Report, URL, E-mail or Content.
3. Specify the options for the link target.
4. When done, click OK to create the link.

To bind a conditional link to an object:

1. Right-click the object and select Link from the shortcut menu to display the Insert Link dialog.
2. Check the Conditional Link checkbox.
3. Click the button to open the Edit Conditions dialog to define a condition using either simple expressions or complex expressions according to your requirements.

   The newly added condition will then be displayed and highlighted in the conditions box in the Insert Link dialog.

4. From the Link Type drop-down list, select the target to which the object will be linked under this condition: Report, URL, E-mail or Content, then specify the options for the link target.
5. Repeat the above steps to add more conditions and define the link target for each condition.

   To edit a condition, select the condition in the Condition box, then click . In the Edit Conditions dialog, edit the expressions as required.

   To remove a condition and the corresponding format, select the condition in the Condition box and click .

   To adjust the priority of a condition, select the condition in the Condition box and then click or .

6. When done, click OK to finish defining the conditional link.

For an illustrated example, see Example of binding a conditional link.

Once a link is added to an object, you can further edit it or remove it.

- To edit a link, right-click the object and select Edit Link from the shortcut menu. In the Edit Link dialog, edit the link according to your requirement.
- To remove a link from an object, right-click the object and click Remove Link on the shortcut menu. In the warning message dialog, click Yes to confirm the removal.

#### Linking a report to another report

A report can be linked to another report, after which the trigger object in the primary report can be clicked in order to jump to the linked report to obtain information about the trigger object.

1. In the Insert Link dialog, select Report as the link type. See the dialog.

2. Click the Browse button beside the Report text field to specify the target web report you want as the linked report.
3. Specifies the window or frame in which to load the linked report from the Target drop-down list.
4. Click the More button to display more options for setting the link.
5. In the Filter tab, click above the Components box to specify which components in the linked report will be interlinked with the primary report.
6. Specify the conditions based on which the link relationship between the primary report and the selected components in the linked report is set up.
   1. Select a component in the Components box.
   2. Click the button above the Field Conditions box and a condition line is added.
   3. Select a field from the drop-down list in the Fields(Primary) column.
   4. Choose an operator from the drop-down list in the OP column. The operator can be "=", "<>", "<", ">", "<=", ">=", or "IN".
   5. Specify the field of the linked report from the drop-down list in the Fields(LinkedReport) column. All fields in the linked report of the same value type as the selected primary report field will be available.
   6. If necessary, you can specify more conditions by clicking the button and then specifying the primary report field, the operator, and the corresponding field in the linked report. Note that the relationship between these conditions is AND, which means that JReport will fetch linked report data which meets all of the conditions.
   7. Repeat the above steps to set link conditions between the primary report and other components in the linked report.
7. From the Default Linked Component drop-down list, select which component in the linked report will be interlinked with the primary report by default.
8. If the linked report uses parameters, go to the Parameters tab, the Target Report Parameters box lists the parameters of the linked report. You can assign fields of the primary report to the parameters. Then, when running the linked report from the link, the field values of the primary report will be assigned to the parameters automatically.
9. If you would like the values of the filter objects such as filter controls and sliders in the primary report to be passed to filter objects in the linked report, go to the Advanced tab to set up the relationship between the filter objects as follows:
   1. Click to add a line.
   2. In the Primary Report Property/Object column, click to select a filter object in the primary report in the Select Value dialog and click OK.
   3. In the Linked Report Property/Object column, click to select a filter object in the linked report in the Select Value dialog and click OK. You need to make sure that values of the filter object in the primary report can be applied to the filter object in the linked report in the same line.
   4. Follow the above steps to set up the relationship between more filter objects.
10. Click OK to apply the settings.

Then, when you click the trigger object in the primary report, you will find that the linked report is displayed according to the specified link conditions. The link is also available when the primary report is opened in HTML, PDF or Excel format with the option Run Linked Report being selected.

If the linked report is opened in the same frame as the primary report in Web Report Studio, you can click on the toolbar to go back to the primary report. Click next to and you will get a drop-down list which lists the original report and the linked targets you have just visited within the link chain. The item checked on the drop-down list is the currently opened page. Select an unchecked item and you will be directed to that target.

Notes:

- When linking reports, you need to avoid link loops. For example, if you have linked report A to report B, then you cannot link report B back to report A again.
- The conditions specified in the Filter tab are used for filtering when the link is triggered at server runtime, that is, only the data that meet the conditions in the linked report will be displayed. However, when the link is triggered in HTML, PDF or Excel result, the conditions are used for setting up search criteria between the two linked reports, which means after you click the trigger object in the primary report, the pages containing the data that meet the conditions in the linked report will be displayed.
- For web reports created in JReport Designer which contain links, if the trigger objects of the links happen to be in some hierarchies (which means you can also perform the go-down action on the objects by single click), you can click the trigger objects to directly open the links in Web Report Studio only when the click priority of the link action is specified to be the highest at report design time. If the priority of the go-down action is specified the highest, you can click the trigger objects to open the links only when you have reached the lowest level of the hierarchies by going down on the objects first.

#### Linking to a URL

1. In the Insert Link dialog, select URL as the link type. See the dialog.

2. Enter the URL in the Hyperlink text box directly. If needed, click the Add Dynamic Field button to insert a field into the URL to compose a dynamic URL.

   For example, you can compose a URL as follows: type in http://www.google.com/search?q= into the Hyperlink text box, then click the Add Dynamic Field button to insert the field Country at the end of the URL. You can then click the label to open a specific URL that directs to a specific country.

3. Specify the frame from the Target drop-down list.

   The Target property works when the link is triggered in Web Report Studio. When the link is triggered in JDashboard, except for Same Frame, all the other targets are treated as New Window.

4. When done, click OK to set up the link.

   You can then click the trigger object to open the URL. The link is also available when the primary report is opened in HTML, PDF or Excel format.

#### Linking to an e-mail

1. In the Insert Link dialog, select E-mail as the link type. See the dialog.

2. Enter the e-mail address in the Hyperlink text box directly. If needed, click the Add Dynamic Field button to insert a field into the e-mail address to compose a dynamic e-mail address.
3. When done, click OK to set up the link.

   You can then click the trigger object to open the e-mail with the information specified in the Hyperlink box. You can further customize the e-mail and send it. The link is also available when the primary report is opened in HTML, PDF or Excel format.

#### Linking to a Blob data type field

You can make an object linked with a Blob data type field. The Blob data type field will then be bound to the object and displayed as a hyperlink. You can download the Blob content by clicking this hyperlink.

In JReport, Blob could be image, Binary, Blob, Clob, LongBlob, LongClob, Varbinary, Longvarbinary, and so on.

To make an object linked to a Blob data type field:

1. In the Insert Link dialog, select Content as the link type. See the dialog.

2. From the Query drop-down list, select the business view which contains the required Blob data type field. Only query based business views that come from the same data source connection as the business view the current report uses are available in the drop-down list.
3. From the Content Type drop-down list, specify the content type for the Blob type data. You can also click the button to bind it with a string type business view element or a record level pass one formula in the selected business view, or with a dynamic formula in the current report.
4. In the File Name text field, specify a file name for the linked Blob type data. You can also click the button to specify a string type business view element or a record level pass one formula in the selected business view to control the file name.
5. From the Content drop-down list, choose a Blob data type field in the selected business view.
6. Click the More button to display more link options.
7. In the Filter tab, specify the filter conditions between the business view used by the current report and the business view that contains the linked Blob content as follows:
   1. Click above the Field Conditions box and a condition line is added.
   2. Select the desired field of the business view used by the current report from the Fields(Primary) drop-down list.
   3. Choose an operator from the drop-down list in the OP column.
   4. Specify the field/formula of the business view that contains the linked Blob content from the drop-down list in the Fields(Linked) column. All fields that are of the same data type as the selected field in the Fields(Primary) column are available in the drop-down list.
   5. If necessary, you can specify more conditions by clicking the button and then specifying the fields and operators accordingly. Note that the relationship between these link conditions is AND, which means that JReport will fetch the linked Blob type data which meets all of the conditions.
8. If the business view that contains the linked Blob content uses parameters, the Parameters tab will be enabled. In this tab, you can assign fields of the business view used by the current report to the parameters. Then, when accessing the Blob type data from the link, the field values will be assigned to the parameters automatically.
9. Click OK to apply the settings.

   You can then click the trigger object to download the Blob content according to the specified conditions. The link is also available when the report is opened in HTML, PDF, or Excel format.

#### Example of binding a conditional link

This section provides an example to show the usage of conditional link and dynamic field.

1. Run the Link.wls located in the Public Reports folder.
2. Click Edit Mode on the toolbar.
3. We will define a link on the table of the report. Right-click on a Product Name value and then select Link from the shortcut menu.
4. In the Insert Link dialog, check the Conditional Link checkbox.
5. Click to define a condition in the Edit Conditions dialog as follows.

6. We will make the field linked to a URL target based on the condition. From the Link Type drop-down list, select URL. In the Confirm dialog, click OK.
7. In the Hyperlink text box, type in http://www.google.com/search?q= and then click the Add Dynamic Field button to insert the field Product Name at the end of the URL.

8. For the product names other than Blue Mountain and Breakfast Blend, we will make them linked to an e-mail target. Check the Others checkbox. A condition named Others will be created.
9. From the Link Type drop-down list, select E-mail. In the Confirm dialog, click OK.
10. In the Hyperlink text box, type in @example.com and then click the Add Dynamic Field button to insert the field Product Name right ahead of @.

11. Click OK in the Insert Link dialog.
12. We will click the product names in the table to view the link result. Click Blue Mountain and a Google search result page with the key text Blue Mountain will be displayed.

13. Click Breakfast Blend and a Google search result page with the key text Breakfast Blend will be displayed.
14. Navigate to the second page of the table, click Sumatra and an e-mail is displayed as follows: