Class TableProcessor
- All Implemented Interfaces:
ConfigurationObject
,Processor<TableProcessor.Input,
TableProcessor.Output>
See also: !table attribute [[examples=verboseExample,datasource_dynamic_tables,customDynamicReport]]
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Input object for execute.static final class
The Output of the processor.Nested classes/interfaces inherited from class org.mapfish.print.processor.AbstractProcessor
AbstractProcessor.Context
Nested classes/interfaces inherited from interface org.mapfish.print.processor.Processor
Processor.ExecutionContext
-
Field Summary
Fields inherited from interface org.mapfish.print.processor.Processor
MDC_APPLICATION_ID_KEY, MDC_JOB_ID_KEY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a new/clean instance of a parameter object.execute
(TableProcessor.Input values, Processor.ExecutionContext context) Perform the process on the input attributes.protected void
extraValidation
(List<Throwable> validationErrors, Configuration configuration) Perform any extra validation a subclass may need to perform.void
setColumns
(Map<String, TableColumnConverter<?>> columnConverters) Set strategies for converting the textual representation of each column to some other object (image, other text, etc...).void
setConverters
(List<TableColumnConverter<?>> converters) Set strategies for converting the textual representation of each cell to some other object (image, other text, etc...).void
setDetailStyle
(String detailStyle) The id of the style to apply to the all columns in the table detail section except first and last columns.void
setDynamic
(boolean dynamic) If true then the JasperReport template will be generated dynamically based on the columns in the table attribute.void
setExcludeColumns
(Set<String> excludeColumns) A set of column names to exclude from the table.void
setFirstDetailStyle
(String firstDetailStyle) The id of the style to apply to the first column in the table detail section.void
setFirstHeaderStyle
(String firstHeaderStyle) The id of the style to apply to the first column in the table header.void
setHeaderStyle
(String headerStyle) The id of the style to apply to the all columns in the table header except first and last columns.void
setJasperTemplate
(String jasperTemplate) The path to the JasperReports template that contains the template for the sub-report.void
setLastDetailStyle
(String lastDetailStyle) The id of the style to apply to the last column in the table detail section.void
setLastHeaderStyle
(String lastHeaderStyle) The id of the style to apply to the last column in the table header.void
setMaxColumns
(int maxColumns) The maximum number of columns to allow.void
setReportWidth
(Integer reportWidth) If dynamic is true, the page width of the table report can be adjusted with this property.Methods inherited from class org.mapfish.print.processor.AbstractProcessor
getInputMapperBiMap, getInputPrefix, getOutputMapperBiMap, getOutputPrefix, getOutputType, setInputMapper, setInputPrefix, setOutputMapper, setOutputPrefix, setPrefix, toString, toString, validate
-
Constructor Details
-
TableProcessor
protected TableProcessor()Constructor.
-
-
Method Details
-
setJasperTemplate
The path to the JasperReports template that contains the template for the sub-report. If dynamic is false then the template will be used without any changes. It will simply be compiled and used as is.If dynamic is true then the template will be used to obtain the column styles and the size of the subreport and to get the position of the first header and field element. The actual field and column definitions will be dynamically generated from the table data that is provided. This may be null if dynamic is false. If it is null then the main template will likely use the generated table datasource directly as its datasource for use in its detail section and the table will be directly in the main template's detail section. Or a later processor may use the table's datasource in someway.
- Parameters:
jasperTemplate
- the template to use for rendering the table.
-
setDynamic
public void setDynamic(boolean dynamic) If true then the JasperReport template will be generated dynamically based on the columns in the table attribute.Default: false
- Parameters:
dynamic
- indicate if the template should be dynamically generated for each print request.
-
setReportWidth
If dynamic is true, the page width of the table report can be adjusted with this property.- Parameters:
reportWidth
- The report width to use.
-
setColumns
Set strategies for converting the textual representation of each column to some other object (image, other text, etc...).Note: The type returned by the column converter must match the type in the jasper template.
- Parameters:
columnConverters
- Map from column name ->TableColumnConverter
-
setConverters
Set strategies for converting the textual representation of each cell to some other object (image, other text, etc...).This is similar to the converters specified for a particular column. The difference is that these converters are applied to every cell of the table (except for the cells of those columns that are assigned a specific converter).
- Parameters:
converters
- A list ofTableColumnConverter
s.
-
setFirstHeaderStyle
The id of the style to apply to the first column in the table header. This is optional.The style must be a style element in the jasperTemplate.
- Parameters:
firstHeaderStyle
- a ref to a style in the japserTemplate
-
setLastHeaderStyle
The id of the style to apply to the last column in the table header. This is optional.The style must be a style element in the jasperTemplate.
- Parameters:
lastHeaderStyle
- a ref to a style in the japserTemplate
-
setHeaderStyle
The id of the style to apply to the all columns in the table header except first and last columns. This value is will be used as a default if either firstHeaderStyle or lastHeaderStyle is not defined. This is required if dynamic is true and is not permitted if dynamic is false.The style must be a style element in the jasperTemplate.
- Parameters:
headerStyle
- a ref to a style in the japserTemplate
-
setFirstDetailStyle
The id of the style to apply to the first column in the table detail section. This is optional.The style must be a style element in the jasperTemplate.
- Parameters:
firstDetailStyle
- a ref to a style in the jasperTemplate
-
setLastDetailStyle
The id of the style to apply to the last column in the table detail section. This is optional.The style must be a style element in the jasperTemplate.
- Parameters:
lastDetailStyle
- a ref to a style in the jasperTemplate
-
setDetailStyle
The id of the style to apply to the all columns in the table detail section except first and last columns. This value is will be used as a default if either firstDetailStyle or lastDetailStyle is not defined. This is required if dynamic is true and is not permitted if dynamic is false.The style must be a style element in the jasperTemplate.
- Parameters:
detailStyle
- a ref to a style in the japserTemplate
-
setMaxColumns
public void setMaxColumns(int maxColumns) The maximum number of columns to allow.- Parameters:
maxColumns
- maximum number of columns to allow.
-
setExcludeColumns
A set of column names to exclude from the table.- Parameters:
excludeColumns
- a set of names of the columns to exclude from the table.
-
createInputParameter
Description copied from interface:Processor
Returns a new/clean instance of a parameter object. This instance's will be inspected using reflection to find its public fields and the properties will be set from theValues
object.The way the properties will be looked up is to
- take the bean property name
- map it using the input mapper, (if the input mapper does not have a mapping for the property then the unmapped property name is used)
- Look up the property value in the
Values
object using the mapped property name - set the value on the instance created by this method. If the value is null an exception
will be thrown UNLESS the
HasDefaultValue
annotation is on the field for the property.
It is important to realize that super classes will also be analyzed, so care must be had with inheritance.
-
execute
public TableProcessor.Output execute(TableProcessor.Input values, Processor.ExecutionContext context) throws Exception Description copied from interface:Processor
Perform the process on the input attributes.- Parameters:
values
- A Java object whose public fields are populated from theValues
object (which is used for transferring properties between processors).context
- The execution context for a print task.- Returns:
- A Java object whose public fields will be put into the
Values
object. The key in theValues
object is the name of the field or if there is a mapping in theProcessor.getOutputMapperBiMap()
map, the mapped name. The key is determined in a similar way as for the input object. - Throws:
Exception
-
extraValidation
Description copied from class:AbstractProcessor
Perform any extra validation a subclass may need to perform.- Specified by:
extraValidation
in classAbstractProcessor<TableProcessor.Input,
TableProcessor.Output> - Parameters:
validationErrors
- a list to add errors to so that all validation errors are reported as one.configuration
- the containing configuration
-