Applying web actions

A web action can be bound to a basic web control, and then when the trigger event, such as click occurs, the web action will be performed. This allows 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 at runtime 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 scrollbar on the object.
Select Fires when the current selection changes.

To bind some web actions to a basic web control:

  1. Right-click the web control 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.
  4. Click and repeat Step 3 and 4 to add more web actions.
  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 report runtime, 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:

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.