Example of delivering a message
This example demonstrates how to deliver a filter user defined message between two library components. It is divided into the following steps:
- Create two library components.
- Define to deliver a filter user defined message between the library components.
- Publish the library components to JReport Server.
- Deliver the message in a dashboard.
Creating the library components
- Open the catalog SampleReports.cat.
- Use the business view WorldWideSalesBV to create two library components and save them as Component 1.lc and Component 2.lc.
For Component 1, create a table which displays the Country, Customer Name and City DBFields, is grouped by Region, and uses Total Sales as the summary field. For Component 2, create a crosstab using Country and Region respectively as the row and column fields, and Total Sales as the summary field.
Defining to deliver a filter user defined message
In this step, we will define to send a filter user defined message from Component 1 when the Click event occurs on the Region group by field in the table, and make Component 2 receive the message and filter on the Region field once it receives the message.
To define to send a filter user defined message on Component 1:
- Right-click the group by field Region and click Send Message > Customize on the shortcut menu to bring out the Send Message dialog.
- In the Events box, check Click as the trigger event, then click on the event to activate the message options on the right.
- From the Message drop-down list, select User Defined, then input 1001 and Filter - Region as the message ID and name.
- Click to add a message line.
- Select the <Input> item from the drop-down list in the Key column and input Region in the text box.
- Select Current Value from the drop-down list in the Value column. String is dispalyed automatically in the Data Type column.
The message is defined as follows:
- Click OK in the dialog to finish defining the message.
To make Component 2 receive the message and filter the Region field:
- Right-click the crosstab and select Receive Message from the drop-down list to display the Receive Message dialog.
- Click to add a message line.
- Select the <Input> item from the drop-down list in the Message ID column, then input 1001 in the text box.
- Input Filter - Region in the text box of the Message Name column.
- Click the blank text box in the Actions column, then click that appears.
- In the Web Action List dialog, select *Filter and click OK to display the Filter dialog.
- Select 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 Region in the text box.
- Click OK to go back to the Receive Message dialog. The message Component 2 receives is defined as follows:
- Click the OK button to finish defining the message.
Publishing the library components
After defining how to deliver the message, save the two library components. Then, start JReport Server and publish the library components along with the catalog SampleReports.cat to the component library in JReport Server. For detailed steps about publishing resources from JReport Designer to JReport Server, see Publishing resources remotely.
Delivering the filter user defined message in a dashboard
When the two library components are inserted into a dashboard, when the Click event occurs on the Region group by field in the table, the message will be delivered between them, and the records in the crosstab will then be filtered according to the specified condition.
To deliver the message in a dashboard:
- Open the JReport Console page, select New Report > Dashboard in the Reports tab to create a dashboard.
- Open the Components panel and browse to the folder where the two library components are published.
- Drag and drop the two library components to the dashboard.
- Click the region APAC in the table in Component 1 to send out the message, then you can see how the crosstab in Component 2 is filtered after it receives the message.
- Turn to Page 7 and click EMEA in the table, then you can see the records about this region is displayed in the crosstab.
- You can also click other regions to see the records about each region.