Class JasperReport7Result
java.lang.Object
org.apache.struts2.result.StrutsResultSupport
org.apache.struts2.views.jasperreports7.JasperReport7Result
- All Implemented Interfaces:
Serializable,Result,StrutsStatics,JasperReport7Constants
Generates a JasperReports report using the specified format or PDF if no format is specified.
This result type takes the following parameters:
- location (default) - the location where the compiled jasper report definition is (foo.jasper), relative from current URL.
- dataSource (required) - the EL expression used to retrieve the datasource from the value stack (usually a List).
- parse - true by default. If set to false, all the parameters will not be parsed for EL expressions.
- format - the format in which the report should be generated. Valid
values can be found in
JasperReport7Constants. If no format is specified, PDF will be used. - contentDisposition - disposition (defaults to "inline", values are typically filename="document.pdf").
- documentName - name of the document (will generate the http header
Content-disposition = X; filename=X.[format]). - reportParameters - an expression used to retrieve a map of report parameters from the value stack. The parameters may be accessed in the report via the usual JR mechanism and might include data not part of the dataSource, such as the user name of the report creator, etc.
- connection - a JDBC Connection which can be passed to the report instead of dataSource
- wrapField - defines if fields should warp with ValueStackDataSource see WW-3698 for more details
This result follows the same rules from StrutsResultSupport.
Specifically, all parameters will be parsed if the "parse" parameter
is not set to false.
Example:
<result name="success" type="jasperReport7"> <param name="location">foo.jasper</param> <param name="dataSource">mySource</param> <param name="format">CSV</param> </result>
or for pdf
<result name="success" type="jasperReport7"> <param name="location">foo.jasper</param> <param name="dataSource">mySource</param> </result>
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringConnection can be passed to the report instead of dataSource.protected Stringprotected Stringprotected Stringprotected Stringprotected StringNames a report parameters map stack value, allowing additional report parameters from the action.protected Stringprotected booleanFields inherited from class org.apache.struts2.result.StrutsResultSupport
DEFAULT_PARAM, DEFAULT_URL_ENCODING, parseLocationFields inherited from interface org.apache.struts2.views.jasperreports7.JasperReport7Constants
FORMAT_CSV, FORMAT_HTML, FORMAT_PDF, FORMAT_RTF, FORMAT_XLSX, FORMAT_XML, STRUTS_JASPER_REPORT_CSV_DELIMITER, STRUTS_JASPER_REPORT_HTML_IMAGE_SERVLET_URLFields inherited from interface org.apache.struts2.StrutsStatics
ACTION_MAPPING, HTTP_REQUEST, HTTP_RESPONSE, PAGE_CONTEXT, SERVLET_CONTEXT, SERVLET_DISPATCHER, STRUTS_ACTION_TAG_INVOCATION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyCustomParameters(ValueStack stack, Map<String, Object> parameters) protected voidapplyLocale(ActionInvocation invocation, Map<String, Object> parameters) protected voidapplyTimeZone(ActionInvocation invocation, Map<String, Object> parameters) protected voiddoExecute(String finalLocation, ActionInvocation invocation) Executes the result given a final location (jsp page, action, etc) and the action invocation (the state in which the action was executed).protected voidexportReport(ActionInvocation invocation, net.sf.jasperreports.engine.JasperPrint jasperPrint, JasperReport7ExporterProvider<?> exporterProvider) protected booleanisAcceptableExpression(String expression) Checks if expression doesn't contain vulnerable codeprotected ValueStackDataSourceprepareDataSource(ValueStack stack) voidsetConnection(String connection) voidsetContentDisposition(String contentDisposition) voidsetDataSource(String dataSource) voidsetDocumentName(String documentName) voidvoidsetNotExcludedAcceptedPatterns(NotExcludedAcceptedPatternsChecker notExcludedAcceptedPatterns) voidsetReportParameters(String reportParameters) voidsetTimeZone(String timeZone) voidsetWrapField(boolean wrapField) Methods inherited from class org.apache.struts2.result.StrutsResultSupport
conditionalParse, conditionalParseCollection, execute, getLastFinalLocation, getLocation, setEncode, setLocation, setParse
-
Field Details
-
dataSource
-
format
-
documentName
-
contentDisposition
-
timeZone
-
wrapField
protected boolean wrapField -
connection
Connection can be passed to the report instead of dataSource. -
reportParameters
Names a report parameters map stack value, allowing additional report parameters from the action.
-
-
Constructor Details
-
JasperReport7Result
public JasperReport7Result()
-
-
Method Details
-
setNotExcludedAcceptedPatterns
public void setNotExcludedAcceptedPatterns(NotExcludedAcceptedPatternsChecker notExcludedAcceptedPatterns) -
doExecute
Description copied from class:StrutsResultSupportExecutes the result given a final location (jsp page, action, etc) and the action invocation (the state in which the action was executed). Subclasses must implement this class to handle custom logic for result handling.- Specified by:
doExecutein classStrutsResultSupport- Parameters:
finalLocation- the location (jsp page, action, etc) to go to.invocation- the execution state of the action.- Throws:
Exception- if an error occurs while executing the result.
-
prepareDataSource
protected ValueStackDataSource prepareDataSource(ValueStack stack) throws jakarta.servlet.ServletException - Throws:
jakarta.servlet.ServletException
-
applyLocale
-
applyTimeZone
-
applyCustomParameters
-
exportReport
protected void exportReport(ActionInvocation invocation, net.sf.jasperreports.engine.JasperPrint jasperPrint, JasperReport7ExporterProvider<?> exporterProvider) throws StrutsException - Throws:
StrutsException
-
isAcceptableExpression
Checks if expression doesn't contain vulnerable code- Parameters:
expression- of result- Returns:
- true|false
- Since:
- 6.0.0
-
setDataSource
-
setFormat
-
setDocumentName
-
setContentDisposition
-
setTimeZone
-
setWrapField
public void setWrapField(boolean wrapField) -
setReportParameters
-
setConnection
-