BackPrevious Page Next PageNext

Delivering Messages Between Library Components

Message types

Sending messages

Receiving messages

Example of delivering a message

A message is a carrier of information that can be delivered between library components. It makes the runtime data synchronization possible. For example, you have two library components containing a crosstab and a table respectively, and both have the field Country. When you click any of the Country value in the crosstab at runtime, you want the crosstab and table to be filtered to show data of this country only. To achieve such synchronization, you can send out a filter message from the Country field in the crosstab and make the crosstab itself and the table receive the same message.

Messages can also be defined at runtime in JDashboard. For details see Synchronizing Data Components in the JReport Server User's Guide.

Message types

The messages that can be delivered between library components includes the built-in messages Filter, Sort, and Parameter, and user customized messages. In a customized message, users can specify to send out multiple messages from one object on different trigger events and edit the message information as they want.

JReport provides the following built-in messages:

A message consists of message ID, message name and message value set. A message ID is a natural number. JReport reserves the IDs from 1 to 1000, which are used in built-in messages, so you can only use IDs beyond 1000 to identify user defined messages. A message name is the name of a message. A message value set is a set of key-value pairs. Each key-value pair has one key and one value. A key or a value can be static or dynamic. A key is of String type, and each value has its own data type, which can be Number, Integer, String, Date, Time, Date Time, Boolean or Currency.

Sending messages

An object in a library component can send out different messages when different events occur on it to ask the message receivers to perform specific web actions defined in the messages.

The following objects in the library component body can be used as the trigger objects to send out messages: labels, data fields (DBFields, formula fields, parameter fields, summary fields), special fields, the category axis, legend and data markers of charts, markers and areas in geographic maps, parameter controls, and the Submit button of parameter form controls.

To send out a message:

Select the trigger object, right-click it and click Send Message > Filter/Sort/Parameter/Customize on the shortcut menu (for the Submit button of a parameter form control, only Parameter and Customize are available).

In addition to the above method, you can also use the Send Message web action to send out messages. To do this:

  1. Do one of the following:
  2. In the Web Action List dialog, select *SendMessage and click OK. The Send Message - Web Action Builder dialog appears.

    Send Message - Web Action Builder dialog

  3. Define the message that will be triggered on the specified event.
  4. Click OK to confirm the settings.
  5. In the dialog you are returned to, add more event lines and repeat the above steps to specify to send out more messages as you want.
  6. Click OK to finish defining the messages to send out.

Receiving messages

The data components (tables, charts, crosstabs, KPIs and geographic maps) in a library component can receive messages that are sent out from the current library component or another library component. When a data component receives a message at runtime, it will perform the web actions defined in the message, such as filtering, sorting itself using conditions specified in the message, running the current or another library component with predefined parameter values, or changing its object properties.

To make a data component receive messages and respond corresponding web actions, take the following steps:

  1. Right-click the data component and select Receive Message from the shortcut menu. The Receive Message dialog appears.

    Receive Message dialog

  2. Click Add button to add a message line.
  3. Select the message you want the data component to receive from the Message ID column.
  4. If a built-in message is selected, the action the message will respond cannot be changed, but you can edit how the action will be performed as you want.

    If a user define message is selected, you can specify the action the data component will respond when it receives the message and define how the action will be performed.

  5. Repeat the above steps to add more messages to receive and define the actions to respond the messages.

    To delete a message, select it and click Remove button. To adjust the display order of the messages in the message box, select a message and click Move Up button or Move Down button.

  6. Upon finish, click OK to close the dialog.

The following details how to make a data component receive different messages.

To receive the built-in Filter message:

  1. In the Receive Message dialog, select 0001 - Filter from the drop-down list of the Message ID column. The filter condition defined in the message will be automatically applied.
  2. If you want to edit the filter condition, click in the Actions column and click Choose button that appears in the text box. The Filter dialog appears.

    Filter dialog

  3. Specify the filter condition by selecting the field on which the filter will be based from the Filter On drop-down list, the operator to compose the condition from the Operator drop-down list and the value of how to filter the field from the Value drop-down list.
  4. If necessary, click Add button to add more filter conditions to filter other field values and specify the relationship between the conditions in the More column.

    To delete a filter condition, select the condition and click Remove button. To adjust the order of the filter conditions, click Move Up button or Move Down button.

  5. Click OK to finish defining the filter conditions.

To receive the built-in Sort message:

  1. In the Receive Message dialog, select 0002 - Sort from the drop-down list of the Message ID column. The sort conditions defined in the message will be automatically applied.
  2. If you want to edit the sort condition, click in the Actions column and click Choose button that appears in the text box. The Sort dialog appears.

    Receive Message dialog

  3. Specify the sort condition by selecting the field on which to sort the records from the Sort On drop-down list, and in which order to sort the records from the Sort Value drop-down list.
  4. If necessary, click Add button to add more sort conditions to sort other fields.

    To delete a sort condition, select the condition and click Remove button. To adjust the order of the sort conditions, click Move Up button or Move Down button.

  5. Click OK to finish defining the sort conditions.

To receive the built-in Parameter message:

  1. In the Receive Message dialog, select 0003 - Parameter from the drop-down list of the Message ID column.
  2. Choose a message type from the Message Info column: Automatic or Customized.

To receive a user defined message and respond the Filter web action:

  1. In the Receive Message dialog, input the ID and name of the user defined message in the Message ID column and Message Name column separately, then click in the Actions column and click Choose button that appears in the text box.
  2. In the Web Action List dialog, select *Filter in the Action Name column and click OK.
  3. In the Filter dialog, specify the filter conditions as required.
  4. Click OK to accept the settings.

To receive a user defined message and respond the Sort web action:

  1. In the Receive Message dialog, input the ID and name of the user defined message in the Message ID column and Message Name column separately, then click in the Actions column and click Choose button that appears in the text box.
  2. In the Web Action List dialog, select *Sort in the Action Name column and click OK.
  3. In the Sort dialog, specify the sort conditions as required.
  4. Click OK to accept the settings.

To receive a user defined message and respond the Change Property web action:

  1. In the Receive Message dialog, input the ID and name of the user defined message in the Message ID column and Message Name column separately, then click in the Actions column and click Choose button that appears in the text box.
  2. In the Web Action List dialog, select *Property in the Action Name column and click OK. The Change Property dialog appears.

    Change Property dialog

  3. Specify the property you want to change and the value for it respectively from the Properties and Value drop-down lists. Only the properties of the data component itself can be changed at runtime.
  4. If necessary, click Add button to add more property lines to change values of other properties.

    To delete a property line, select it and click Remove button. To adjust the order of the properties, click Move Up button or Move Down button.

  5. Click OK to accept the settings.

To receive a user defined message and respond the Parameter web action:

  1. In the Receive Message dialog, input the ID and name of the user defined message in the Message ID column and Message Name column separately, then click in the Actions column and click Choose button that appears in the text box.
  2. In the Web Action List dialog, select *Parameter in the Action Name column and click OK. The Parameter dialog appears.

    Parameter dialog

  3. 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.
  4. Specifies whether to apply the action to run another library component or refresh the current. If you choose to run another library component, click the Browse button to specify the library component, then select the window or frame in which the library component will be opened from the Target Frame drop-down list.
  5. If the specified library component contains parameters, the parameters will be automatically listed in the parameters box. Specify the value for each parameter. You can also click Add button to add more parameter lines to specify other parameter values.
  6. To delete a parameter line, select it and click Remove button. To adjust the order of the parameters, click Move Up button or Move Down button.
  7. Click OK to accept the settings.

Note: In the drop-down lists for editing the conditions to respond a message, you may find that some items have the icon Message Key icon ahead of them and they are listed under the Message Key node. If you choose an item of this type, it means the item will not be used directly in a condition, instead, it will be mapped to a key in the message and JReport will find the value that is specified to the key from the message first and then use that value to compose the condition.

Example of delivering a message

This example demonstrates how to deliver a filter user defined message between two library components in order to synchronize the data components in them. It contains the following tasks:

Task 1: Create two library components

  1. Make sure SampleReports.cat is the currently open catalog file. If not click File > Open Catalog to open it from <install_root>\Demo\Reports\SampleReports.
  2. Use the business view SaleStat in Data Source 1 to create two library components and save them as Component 1.lc and Component 2.lc.

    For Component 1, create a chart which displays in the clustered bar 2-D chart type, shows Assigned Region on X-Axis and Total Actual as Bar Length. For Component 2, create a crosstab using Order ID and Assigned Region respectively as the row and column fields, and Total Actual as the summary field. Apply the style Commercial to both of them.

Task 2: Send out a filter user defined message from the chart

In this task, we will send a filter user defined message from the chart in Component 1 when the Click event occurs on any legend entry value.

  1. Open Component 1.lc.
  2. Right-click the chart legend and click Send Message > Customize on the shortcut menu to bring out the Send Message dialog.
  3. In the Events box, check Click as the trigger event, then click on the event to activate the message options on the right.
  4. From the Message drop-down list, select User Defined, then input 1001 and Filter - Assigned Region as the message ID and name.
  5. Click Add button to add a message line.
  6. Select the <Input> item from the drop-down list in the Key column and input Assigned Region in the text box.
  7. Select Current Value from the drop-down list in the Value column. String is displayed automatically in the Data Type column.

    The message is defined as follows:

    Send Message dialog

  8. Click OK to finish defining the message to be sent out.
  9. Save the library component.

Task 3: Make the two data components receive the same message

In this task we will make the chart and crosstab in the two library components receive the same filter message to filter on the Assigned Region values when they receive the message sent out from a chart legend entry.

  1. Right-click the chart platform and select Receive Message from the shortcut menu to display the Receive Message dialog.
  2. Click Add button to add a message line.
  3. Select the <Input> item from the drop-down list in the Message ID column, then input 1001 in the text box.
  4. Input Filter - Assigned Region in the text box of the Message Name column.
  5. Click the blank text box in the Actions column, then click Choose button that appears.

    Receive Message dialog

  6. In the Web Action List dialog, select *Filter and click OK to display the Filter dialog.
  7. Select Assigned Region from the Filter On drop-down list, keep the default operator, then select <Input> under the Message Key node in the Value drop-down list and input Assigned Region in the text box.

    Filter dialog

  8. Click OK to go back to the Receive Message dialog. The message Component 1 receives is defined as follows:

    Receive Message dialog

  9. Click OK, then save the library component.
  10. Open Component 2.lc.
  11. Right-click the crosstab and select Receive Message from the shortcut menu.
  12. In the Receive Message dialog, specify the message the crosstab is going to receive as shown above.
  13. Save the library components.

Task 4: Publish the library components

Start JReport Server and publish the library components along with the catalog SampleReports.cat to the component library in JReport Server. For details about publishing resources from JReport Designer to JReport Server, see Publishing resources remotely.

Task 5: Deliver the message in a dashboard for data synchronization

  1. Open the JReport Server console > Resources page, click New > Dashboard on the task bar. A blank dashboard is displayed in JDashboard.
  2. Open the Resources panel and browse to the folder where the two library components are published.
  3. Drag and drop the two library components to the dashboard.

    Components in Dashboard

  4. Click Asia-Pacific in the chart legend to send out the message. The chart and the crosstab are both filtered to show data in the Asia-Pacific region only.

    Data in the Asia-Pacific Region for Chart and Crosstab

  5. Click the Clear Filters button on the toolbar to clear the filter in both components.
  6. Click Europe, Middle East, Africa in the chart legend and the chart and crosstab are filtered based on this region now.

    Data in Europe, Middle East, and Africa for Chart and Crosstab

BackPrevious Page Next PageNext