### Applying web actions

A web action can be bound to a web control, and then when the trigger event, such as click, resize occurs, the web action will be performed. And thus, you can customize a web control, make it respond to some events, and execute corresponding actions, such as sorting and filtering. For example, you can insert a button in JReport Designer and associate an action with the button's onclick event. Then, when you view the report in JReport Web and click the button, 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 scroll bar on the object.
Select | Fires when the current selection changes.

To bind some web actions to a web control:

1. Insert the required web control into your report by dragging the corresponding button from the Toolbox panel.
2. Right-click the web control, and then select Display Type from the shortcut menu.
3. In the Web Behaviors box of the Display Type dialog, choose an event from the Events column, and then click in the Actions column.
4. 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 or Parameter, the Web Action Builder dialog will then appear. Specify the settings according to your requirements and then click OK to return to the Display Type dialog.
   - If the selected action needs no parameter, the Web Action List dialog will be closed and you will return to the Display Type dialog.
   - If the selected web action needs parameter(s), the Parameters dialog will be displayed for you to input the parameter value(s). 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. Click OK after specifying to return to the Display Type dialog.
5. Click and repeat Step 3 and 4 to add more web actions.
6. 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.
7. Click OK to apply the settings and close the Display Type dialog.

Now, when you run the report in JReport Web, the occurrence of any of the specified events will fire the actions that have been bound to the web control. For detailed usages of these web actions, see the following sections:

- Filter
- Sort
- Parameter
- Other web actions
- Example of applying web actions

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`.