This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/struts-site.git


The following commit(s) were added to refs/heads/main by this push:
     new 79467b8c0 WW-3245 docs(jasperreports): describe filling from report 
parameters (#330)
79467b8c0 is described below

commit 79467b8c01746f6e6b479d529f0d6d2ba3134f8c
Author: Lukasz Lenart <[email protected]>
AuthorDate: Sat Sep 12 10:57:24 2026 +0200

    WW-3245 docs(jasperreports): describe filling from report parameters (#330)
    
    Companion to apache/struts#1919: dataSource is no longer required, and a
    report can be filled from its parameters alone (HIBERNATE_SESSION,
    CSV_INPUT_STREAM, REPORT_DATA_SOURCE, ...) when neither dataSource nor
    connection is set.
    
    Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
---
 source/plugins/jasperreports/index.md | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/source/plugins/jasperreports/index.md 
b/source/plugins/jasperreports/index.md
index cf50775d7..2c4a553a1 100644
--- a/source/plugins/jasperreports/index.md
+++ b/source/plugins/jasperreports/index.md
@@ -29,7 +29,9 @@ package, which contains the `jasper` result type.  Then, 
simply use the result t
 The result 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)
+ - dataSource - the EL expression used to retrieve the datasource from the 
value stack (usually a List). Since 7.4.0
+   it is optional: when neither `dataSource` nor `connection` is set, the 
report is filled from its parameters alone
+   (see [Filling from report parameters](#filling-from-report-parameters))
  - parse - `true` by default, if set to false, the location param will not be 
parsed for EL expressions
  - format - the format in which the report should be generated. Valid  values 
can be found in `JasperReportConstants`. 
    If no format is specified, PDF will be used
@@ -69,6 +71,33 @@ or for pdf:
 </result>
 ```
 
+### Filling from report parameters
+
+Since 7.4.0, when neither `dataSource` nor `connection` is set the result calls
+`JasperFillManager.fillReport(report, parameters)` and JasperReports resolves 
the data from the parameter map,
+exactly as it does when used standalone. Hand the object the report's query 
executer expects over via
+`reportParameters` - a Hibernate `Session` under `HIBERNATE_SESSION`, a 
`CSV_INPUT_STREAM`, a `JSON_INPUT_STREAM`,
+or a ready `REPORT_DATA_SOURCE` / `REPORT_CONNECTION`. The report keeps its 
own `queryString` (HQL, CSV, JSON, ...)
+and no intermediate `List` has to be built in the action.
+
+```xml
+<result name="success" type="jasper">
+    <param name="location">foo.jasper</param>
+    <param name="reportParameters">reportParameters</param>
+</result>
+```
+
+```java
+public Map<String, Object> getReportParameters() {
+    return Map.of("HIBERNATE_SESSION", session);
+}
+```
+
+Query executers other than JDBC, CSV and XPath ship as separate JasperReports 
artifacts (for example
+`net.sf.jasperreports:jasperreports-hibernate`); add the one your report needs 
to the application's dependencies.
+When the parameter map carries nothing the executer can use, the outcome is 
JasperReports' own - it is not checked
+by the plugin.
+
 ### Settings
 
 This plugin doesn't provide any global settings.

Reply via email to