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:
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:
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:
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:
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.