Jasper printer component
This component is used to automatically print a document based on an event. Additionally, you can also generate the PDF or an RTF object of a document. It is a standard XML-based component: accepts XML as input and provides an identical output XML.
For example, printing a pick list in a store for store pick-up is an example where the store does not maintain the inventory. In this case, the website where the order is placed or a call center captures orders for store pick-up. These orders are sent down to the store for processing. A store inventory control associate periodically checks to see if there are any orders to be picked. If there are, the associate can print a paper pick list to pull the products required off the retail floor. In some cases, the print can be triggered automatically when an order is received at the store.
A document can be printed conveniently by a single click from the console. This is supported by using flow execution and the printer component.
Jasper Print component can be used to generate a PDF report and stream it down via HTTP response. This can be done by configuring a service with a Jasper Print component and selecting the "Jasper Print Object" option. This service is now invoked by making a HTTP call to the "InteropJasperServlet" servlet and passing the input XML "locale" to the service and the name of the service that you created for generating PDF objects. These services are created in the Service Definition Framework (SDF). For more information about SDF and how to create service, see Service definition framework.
You can also audit the success and failure of the printing events using the print transaction defined under the general process type. This transaction is configurable and has two events: Print.ON_SUCCESS and Print.ON_FAILURE. The ON_FAILURE event is raised only for service suspend exceptions such as print failures.
The following table provides the Jasper printing configuration properties:
Field | Description |
---|---|
General Tab | |
Jasper Report | This is a compiled Jasper file. The file name supports variables in both a standard and enhanced variable format. |
Report Select Exp | Specify the element to be sent as the root of the report. By default, the entire XML is used. An error is thrown, if this field is given but does not resolve to an element. |
Locale | Specify the locale for translating the literals in the report. The data in the XML can be localized using the defaulting component discussed in Defaulting component. |
Use Sterling Order Management System Software Resource Bundle | If checked, all literals in the report are translated to the requested locale using the Sterling Order Management System Software Resource Bundle. |
Output Tab | |
Printer | Select this option to specify a printer to use. |
Printer Name | Enter the XML path pointing to the printer to use. |
Number of Copies | Enter the number of copies you wish to print. |
Variables Tab | |
Variable Name | The name of the parameter to be passed to the validator method. |
Variable Value | The value of the parameter to be passed to the validator method. |
To allow custom print formats, the configuration of the print component supports changing report file names based on an input XML. For example, if the input XML contains the file name:
${jasperfolder}/compiled/${orgcode}/report.${doctype}.jasper
First, all variables are resolved against the variables defined in the Variables tab:
orgcode
g xml:/Order/@OrganizationCode
doctype
g xml:/Order/@DocumentType
The remaining variables are resolved against the yfs.properties
file.
In this case, the ${jasperfolder} variable is resolved from the yfs.properties
definition: jasperFolder=/someCustomJasperFolder
.
To modify this property, add an entry for it in the <INSTALL_DIR>/properties/customer_overrides.properties
file.
So, with the input of <Order
OrganizationCode="DEFAULT" DocumentType="0001" .... />
the
expression resolves to: /someCustomJasperFolder/compiled/DEFAULT/report.0001.jasper.
An exception is thrown if an error occurs when processing the report. For example, an exception is thrown if the file name is invalid. A service suspend exception is thrown while printing the report enabling the ability to pause an asynchronous service.