Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This AraxisMerge image shows the before (on the left) and the after (on the right). The overview of the changes are as follows:


  1. Add a report header that displays the region;
  2. Change the field type for the column header from label to message-field;
  3. And create property references for the incoming parameters.
Adding the Report Header

To add the report header, either type, or paste in the following XML fragment over the existing <reportheader/> line in the XML document:

Panel

<reportheader fontname="SansSerif" fontsize="11" fontstyle="bold">
    <message-field height="18" alignment="center" width="100%" x="0%" y="0">Region: $(region)</message-field>
</reportheader>

Changing the Field Type

Why would we want to change the field type? Well, in JFreeReport, a label is simple text. A message-field will do evaluation on the parameters. For this example, we want to evaluate the value of the column header parameter, and display that value. The new field looks like this:

Panel

<message-field color="#D0D0D0" fontname="SansSerif" fontsize="12" fontstyle="bold"  height="18" vertical-alignment="middle" alignment="left" width="50%" x="0%" y="0">$(columnTitle)</message-field>

Adding the Property References

Before JFreeReport can use the incoming parameters, they must have a property-ref entry in the <functions> section.

Panel

<property-ref name="columnTitle"/>
<property-ref name="region"/>

Publish the Report to the Pentaho Pre-configured Installation

That's it. Now, we want to publish our report to the local Pre-configured Installation, with a starter action sequence.

  1. From the File menu, select Publish | To Location....
  2. You will be prompted with a file system navigation dialog. Navigate to the <Pre-configured Installation root>/pentaho-solutions/samples/reporting directory.
  3. Select OK, and the report definition along with a starter action sequence file will be generated in that directory.

Finishing the Action Sequence Using the Pentaho Design Studio

The action sequence that is generated from the Report Design Wizard only sets up the step to run the report we just created. We need to add a few steps to the action sequence to achieve our goal:

  1. We need to add a SecureFilterParameter component, which provides the ability to prompt the user for the dynamic values in our report (which region, which column we would like in the query (department or position), and report output format (pdf, xls, or html)).
  2. We need to add a Javascript rule that will accept the query column parameter and the region parameter from the SecureFilterParameter component, and builld them into our report query.
  3. We need to add a Javascript rule that will use the query resultset to find the title to use on the dynamic column in our report, Position Title or Department.
  4. Finally, we need to stitch up the report component to use our newly defined parameters and dynamic query.

We'll use the Pentaho Design Studio to fill out our action sequence. If you are not familiar with the Pentaho Design Studio or action sequences, take time now to review the Pentaho Design Studio User's Guide and Creating Pentaho Solutions Guide. Both can be found on our downloads site.

  1. Start the Pentaho Design Studio.
  2. The easiest way to work on your new action sequence is to have the pentaho-solutions directory (under the Pre-configured Installation root) set up as a Simple Eclipse Project. From the File menu, choose New... | Project.
  3. In the dialog, choose the Simple option in the list, then Project. Click the Next button.
  4. Name your project TechTipSolution, uncheck the "use Default" option, and Browse to the <Pre-configured Installation>/pentaho-solutions directory on your local machine. Click the Next button.
  5. Click Finish. You should have a new Eclipse project named TechTipSolution in your Navigator view.
  6. Navigate to <Pre-configured Installation root>/pentaho-solutions/samples/reporting directory, and open the .xaction file with the name of your report prefixed. In our example, the file name is DynamicColumnSample.xaction, since DynamicColumnSample is what we named our report in the Report Design Wizard.

Now, we can get to work finishing our action sequence.

General Action Sequence Information

  1. The first screen displayed is the General information about your action sequence. The fields are pretty self explanatory, fill in this information for your action sequence.