NexJ Logo

Managing and passing parameters

Parameters define which values are passed to the report from NexJ CRM at run time. They enable the user to include or exclude information from the report on-the-fly without having to edit the Jaspersoft Studio Professional template. Information is passed from the NexJ application to the JasperReports reporting engine.

Parameters act as the behavior guide for a report when it is generated and supply additional data to the context of the report. Parameters consist of a name, class type, default value expression, and description. The report executes expressions in the parameters through a report command class which defines the report's structure.

Parameters allow users to customize the report before it is created. For instance, a user might want to show or hide certain information to filter the report's contents. The following syntax is used to refer to parameters in reports: $P{parameterName}.

For example, a parameter can be created using the showAddresses attribute. The user can include or exclude contact address information on-the-fly from NexJ CRM without having to edit the report template in Jaspersoft Studio Professional.

Configuring parameter passing involves creating a report command class, form, and screen, string resource, and new parameter in Jaspersoft Studio Professional.

Creating report command classes

Configuring passing parameters requires creating a new report command class to specify which attribute in the report will have a dynamic value at run time. The report command class should have an attribute name that reflects the parameter specified in Jaspersoft Studio Professional.

For this example, the showAddresses attribute will be used as a passing parameter. When the report is created from NexJ CRM, the user can choose if the addresses will be included in the report by selecting or clearing a checkbox.

To create the report command class:

  1. In the NexJ Studio Business Model layer, create a new class.
    For example, the report command class is named ContactReportCommand.
  2. Open the newly created class, and in the Attributes tab, click the Add button .
    For example, the name is set to showAddresses. The type will be set to boolean providing the class with two options: true (show) or false (hide).
  3. In the Value tab, enter the initializer for the command class in the Initializer field.
    For example, #t is used to show the value of the showAddresses attribute in the report when the boolean value is set to true.
  4. Click the Save button  to save your changes.

Your report command class has been created.

Next, create a new form and screen to display the report's user interface in NexJ CRM.

Creating report forms

Reports require a form and screen to be accessed from NexJ CRM. The form structures the user interface used to generate the report. It contains control items to set the value of the parameters at run time and a button to initiate the report's creation.

The NexJ Solutions business model contains an existing form (AllReportCommandDetail) that can be copied to quickly integrate reports into the application.
To create the report form:

  1. In the NexJ Studio Presentation layer, create a copy of the AllReportCommandDetail form.
    For example, it is named ReportContactDetail.
  2. Open the newly created form. In the Overview tab, click the Select button  in the Class field.
    The Select Class view opens.
  3. Select the report command class and click OK. This associates the form with the report command class to pass the parameter's value.
    For example, select the ContactReportCommand class.
  4. Modify the form to incorporate the parameter passing by adding a checkbox command.
    For example, add a checkbox to set the boolean value of the showAddresses attribute. If selected, the value will be set to true (#t) and the address will be shown. Otherwise, it will be set to false (#f) and they will not display in the report.
  5. Click the Save button to save your changes.

The report form is created.

Next, create the screen and insert this form as a FormRef.

Creating report screens

Create a screen for a report to make it accessible from NexJ CRM. Users can generate the report using the Reports button  on the Contacts, Schedules, and Service Requests workspaces after it has been added to the NexJ application as a external report. The screen will display the information contained in the report form to NexJ users.

The NexJ Solutions business model contains an existing screen (AllReportCommand) that can be copied to quickly integrate reports into the application.
To create the report screen:

  1. In the NexJ Studio Presentation layer, create a copy of the AllReportCommand screen.
    For example, it is named ReportContact.
  2. Open the newly created screen and click the Overview tab.
  3. In the Outline view, select the frmAllDetailReportParameters form reference.
  4. In the Properties view, change the form property to match the name of your report form.
    For example, it is changed to ReportContactDetail.
  5. Click the Save button  to save your changes.

Your report screen is created and connected to the form.

Creating string resources

The report command class requires a string resource to pass parameters from the NexJ application to JasperReports. String resources can pass parameter values through the Caption field.

To create a string resource and add it to the parameter passing command:

  1. In the NexJ Studio Resources layer, click the Strings tab.
  2. In the string list, open idsr.en.
    The String Properties screen opens.
  3. Click the Add New ID button .

    Info

    If you are unable to add new string ids, right-click the isdr.en string and select Customize.

  4. Set the Id value to classcaption.classname.parametername and add a descriptive en value.
    For example, set the Id value to idsr.ContactReportCommand.ShowAddresses and set the en value to Address report parameter.
  5. Click the Save button  to save your changes.
  6. In the NexJ Studio Presentation layer, click the Forms tab.
  7. Navigate to the form used for the report and click the control that uses the parameter.
    For example, open the ReportContactDetail form and select the checkbox.
  8. In the Properties view, enter the string resource Id in the caption field.
    For example, set the caption to idsr.ContactReportCommand.ShowAddresses.
  9. Click the Save button  to save your changes.


Your new string resource is added. The command you created in Creating report forms can now control the inclusion of the parameter in the report before it is created from NexJ CRM.

After creating the string resource and connecting it to the report form, you must add the parameter in Jaspersoft Studio Professional to fully pass the parameter value from NexJ CRM to JasperReports. This allows the NexJ application to invoke the report with information using the parameter.

When you add the parameter in Jaspersoft Studio, and enter the parameter name, the parameter name must be identical to the name of the attribute it references in the NexJ Solutions business model.

When you select the parameter class in Jaspersoft Studio, it should reflect the attribute type defined in the NexJ Model. For example, set it tojava.lang.Boolean.