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 include the built-in messages Filter, Sort, Parameter and On-screen Filter, 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:

Both built-in Filter messages and built-in On-screen Filter messages replace one another when the same field or category is involved. For example, when a data component receives two messages one after another: the first is a filter condition Country=USA and the second is City=London, the final filter condition applied to the data component will be City=London while Country=USA is removed. However when involving different fields or categories, built-in Filter messages still replace each other while built-in On-screen Filter messages can work with each other and with built-in Filter messages. For example, suppose that the first message is a filter condition Country=USA and the second is Sales Year=2019, as long as one of the two messages is a built-in On-screen Filter message, the final filter condition applied to the data component will be Sales Year=2019 and Country=USA. But if both are built-in Filter messages, the result will be Sales Year=2019. Choose the proper filter message type according to your needs.

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 for 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/On-screen Filter/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 one. 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, changing its object properties, removing filter conditions, or drilling through data.

To make a data component receive messages and respond to 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 the built-in On-screen Filter message:

  1. In the Receive Message dialog, select 0004 - On-screen 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 On-screen Filter dialog appears.

    On-screen 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, 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.

    To delete a filter condition, select the condition and click Remove button.

  5. Click OK to finish defining the filter conditions.

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

The Filter web action enables you to filter the records of the data component when it receives the message.

  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 to the On-screen Filter web action:

The On-screen Filter web action enables you to filter the records of the data component when it receives the message.

  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 *On-screen Filter in the Action Name column and click OK.
  3. In the On-screen Filter dialog, specify the filter conditions as required.
  4. Click OK to accept the settings.

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

The Remove Filter web action enables you to remove filters from the data component when it receives the message.

  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 *Remove Filter in the Action Name column and click OK.
  3. In the Remove Filter dialog, specify whether to remove filters (created using the Filter dialog, the Filter option on a field’s shortcut menu, and *Filter web action) and *on-screen filters (created by *On-screen Filter web action) from the data component. For *on-screen filters, you can also specify to remove filter conditions related to certain data fields. To do this, first uncheck the All Fields option, then click Add button to add a row, click in the row and select a field from the drop-down list. You can add more fields if required. To remove an unwanted field, select it and click Remove button.

    Remove Filter dialog

  4. Click OK to accept the settings.

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

The Sort web action enables you to sort the records of the data component when it receives the message.

  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 to the Parameter web action:

The Parameter web action enables you to run a library component, especially a library component with parameters using predefined parameter values, or re-run the current library component with predefined parameter values when the message is received.

  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.

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

The Change Property web action enables you to change properties of the data component when it receives the message.

  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 to the Go Down web action:

The Go Down web action enables you to drill through data of the data component to the lower level when it receives the message.

  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 *Go Down and click OK. The Go Down dialog appears.

    Go Down dialog

  3. In the Go Down On column, specify the field on which the go-down action will be performed. For a geographic map, it is Current Layer and cannot be changed.
  4. In the Use Hierarchy column, specify the hierarchy that the go-down action will be performed according to. You can select a hierarchy in the business view or a web control in the library component which retrieves a hierarchy name at runtime. For a geographic map, the Built-in hierarchy is used and cannot be changed.
  5. In the By Value column, input a value of the specified field to go down to the lower level with a filter condition SpecifiedField=TheValue. You can also use a web control to retrieve a value at runtime.
  6. Click OK to accept the settings.

To receive a user defined message and respond to the Go Up web action:

The Go Up web action enables you to drill through data of the data component to the higher level when it receives the message.

  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 *Go Up and click OK. The Go Up dialog appears.

    Go Up dialog

  3. In the Go Up On column, specify the field on which the go-up action will be performed. For a geographic map, it is Current Layer and cannot be changed.
  4. In the Use Hierarchy column, specify the hierarchy that the go-up action will be performed according to. You can select a hierarchy in the business view or a web control in the library component which retrieves a hierarchy name at runtime. For a geographic map, the Built-in hierarchy is used and cannot be changed.
  5. Click OK to accept the settings.

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

The Go To web action enables you to change a data field of the data component when it receives the message.

  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 *Go To and click OK. The Go To dialog appears.

    Go To dialog

  3. In the Go To On column, specify the field on which the go-to action will be performed.
  4. In the To Column column, specify another field that the Go To On field will be converted to. You can also use a web control in the library component to retrieve a field name at runtime.
  5. In the By Value column, specify whether the go-to action will be performed by filtering a value of the Go To On field. If yes, check the By Value checkbox and then input a value or select a web control to retrieve a value at runtime. Skip this step if a crosstab aggregate field is selected in the Go To On column.
  6. 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. Double-click any bar of the chart. Then in the Fill tab of the Format Bar dialog, check Vary Colors by Color List to make the bar colors vary and then click OK.
  3. Right-click the chart legend and click Send Message > Customize on the shortcut menu to bring out the Send Message dialog.
  4. In the Events box, check Click as the trigger event, then click on the event to activate the message options on the right.
  5. From the Message drop-down list, select User Defined, then input 1001 and Filter - Assigned Region as the message ID and name.
  6. Click Add button to add a message line.
  7. Select the <Input> item from the drop-down list in the Key column and input Assigned Region in the text box.
  8. 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

  9. Click OK to finish defining the message to be sent out.
  10. 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. In 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