### Applying web actions to a label

A label can be bound with some web actions. This allows you to customize a label to make it respond to some events, and execute corresponding actions, such as sorting and filtering. For example, you can insert a label in JReport Designer and associate an action with the label's onclick event. Then, when you view the report at runtime and click the label, the defined operation will be executed.

The following table lists the events that can be used to trigger web actions:

Events | Description
--- | ---
Blur | Fires when the object loses the input focus.
Data Change | Fires when the contents of the object or selection have changed.
Click | Fires when the user clicks the left mouse button on the object.
onContextMenu | Fires when the user clicks the right mouse button on the object, opening the shortcut menu.
Double_Click | Fires when the user double-clicks the object.
Focus | Fires when the object receives focus.
Key Down | Fires when the user presses a key.
Key Press | Fires when the user presses an alphanumeric key.
Key Up | Fires when the user releases a key.
Mouse Down | Fires when the user clicks the object with either mouse button.
Mouse Move | Fires when the user moves the mouse over the object.
Mouse Out | Fires when the user moves the mouse pointer outside the boundaries of the object.
Mouse Over | Fires when the user moves the mouse pointer into the object.
Mouse Up | Fires when the user releases a mouse button while the mouse is over the object.
Resize | Fires when the size of the object is about to change.
Scroll | Fires when the user repositions the scroll box in the scrollbar on the object.
Select | Fires when the current selection changes.

To bind some web actions to a label:

1. Right-click the label and select Display Type from the shortcut menu.
2. In the Web Behaviors box of the Display Type dialog, choose an event from the Events column, then click in the Actions column and click that appears in the text box.
3. In the Web Action List dialog, select the required action and then click OK. See the dialog.

   - If the selected web action is Filter, Sort, Parameter, Property or SendMessage, the corresponding web action builder dialog appears. Specify the settings according to your requirements.
   - If the selected action needs no parameter, the Web Action List dialog is closed.
   - If the selected web action needs parameter, the Parameters dialog appears for you to input the parameter value. For parameters that refer to instance name, you can input the mapping name of the instance, or the display name plus the prefix "&" as the parameter value.

   Note: Web actions are not supported on web reports, and the Property and SendMessage web actions are available to library components only at present.

4. Click in the Display Type dialog and repeat Step 3 and 4 to add more web actions. If a web action is not required, click to remove it.
5. Adjust the order of the added web actions by clicking or . Then, when an event that has been bound with more than one action happens, the upper action will be triggered first.
6. Click OK to apply the settings and close the Display Type dialog.

Then, at runtime, when any of the specified events occurs on the label, the web action defined on the event will be triggered.

#### Filter

The Filter web action enables you to filter the records in a data component.

To bind the Filter web action to a label:

1. In the Web Action List dialog, select *Filter and click OK. The Filter - Web Action Builder dialog appears. See the dialog.

2. From the Get Input From drop-down list, specify where to get the input, which may be a form, or other in report.
3. From the Apply Action To drop-down list, select a data component in the current report, whose records will be filtered.
4. In the Filter On column, specify the field on which to filter the records. The field may be a column in the component, or be specified by the value of a web control.
5. Specify the operator and value. The value may be input by yourself, or be the value of a web control.
6. If necessary, specify And or Or in the More column so as to add a new filter condition or you can click to add a new filter condition.

   To delete a filter condition, select it and click . To adjust the order of the filter conditions, click or .

7. Click OK to accept the filter conditions.

At runtime, when the specified event occurs on the label, the selected data component will be filtered based on the predefined conditions.

#### Sort

The Sort web action enables you to sort the records in a data component.

To bind the Sort web action to a label:

1. In the Web Action List dialog, select *Sort and click OK. The Sort - Web Action Builder dialog appears. See the dialog.

2. From the Get Input From drop-down list, specify where to get the input, which may be a form, or other in report.
3. From the Apply Action To drop-down list, select a data component in the current report, whose records will be sorted.
4. In the Sort On column, specify the field on which to sort the records. The field may be a column in the component, or be specified by the value of a web control.
5. Specify the sort value. The value may be Ascending or Descending, or be the value of a web control.
6. If necessary, click to add a new sort condition.

   To delete a sort condition, select it and click . To adjust the order of the sort conditions, click or .

7. Click OK to accept the sort conditions.

At runtime, when the specified event occurs on the label, the selected data component will be sorted based on the predefined conditions.

#### Parameter

The Parameter web action enables you to run a report, especially a report with parameters.

To bind the Parameter web action to a label:

1. In the Web Action List dialog, select *Parameter and click OK. The Parameter - Web Action Builder dialog appears. See the dialog.

2. Specify the handler which will receive the parameters of the web action. The handler may be the default one in the current server, or in another server specified by Customized Path.
3. From the Get Input From drop-down list, specify where to get the input, which may be a form, or other in report.
4. Specifies whether to apply the action to run a report or refresh the current. If you choose to run a report, click the Browse button to specify the report or use a web control to retrieve the report name at runtime, then select the window or frame in which the report will be opened from the Target Frame drop-down list.
5. The parameters used by the specified report are automatically listed in the parameters box. Specify the value for each parameter.
6. Click OK to accept the parameter values.

At runtime, when the specified event occurs on the label, the selected report will run using the specified parameter values.

#### Property

The Property web action enables you to make the properties of an object changed at runtime, however, it is available to the following objects in library components only: fields and labels in tables/crosstabs, some chart elements such as legend, chart axis and so on, markers and areas in geographic maps, as well as labels, parameter controls and the Submit buttons of parameter form controls which are not in the library components' configuration panels.

To bind the Property web action to a label:

1. In the Web Action List dialog, select *Property and click OK. The Change Property - Web Action Builder dialog appears. See the dialog.

2. From the Apply Action To drop-down list, select the object the properties of which you want to change.
3. In the Properties column, specify the property you want to change. All the properties of the object you select from the Apply Action To drop-down list are listed here.
4. In the Value column, input the value of the property.
5. If necessary, click to add a new line to change a property.

   To delete a property line, click . To adjust the order of the properties, click or .

6. Click OK to accept the property values.

At runtime, when the specified event occurs on the label, the property values will be applied to the selected object.

#### SendMessage

The SendMessage web action enables you to send out a message when a specific event occurs on a certain object in a library component. For more details about this web action, refer to Sending out messages.

Note: You can define your own web actions by adding API functions into both the file API.js located at `<designer_install_root>\lib\html\javascript\dhtml` and the same-name file located at `<server_install_root>\public_html\dhtmljsp\js`.