I am trying to use DynamicJasper 5.0.0 with Struts 2.3.4. I am using following code to show data in PDF format
In action class
try {
FastReportBuilder drb = new FastReportBuilder();
DynamicReport dr = drb.addColumn("Size", "size", String.class.getName(), 30).setTitle("Size List Report").setSubtitle("This report was generateed at" + new Date()).setUseFullPageWidth(true) //make colums to fill the page width
.setPrintBackgroundOnOddRows(true).build();
JRDataSource ds = new JRBeanCollectionDataSource(getSizeList());
JasperPrint jp = DynamicJasperHelper.generateJasperPrint(dr, new ClassicLayoutManager(), ds);
JasperViewer.viewReport(jp); //finally display the report report [/CODE]
} catch (Exception e) {
System.out.println("Exception");
}
return SUCCESS;
struts.xml
<package name="expotpkg" extends="struts-default, json-default,jasperreports-default">
<result-types>
<result-type name="dynamic-jasper" class="ar.com.fdvs.dj.webwork.DJResult"/>
</result-types>
<action name="DownloadSizePdf" class="iland.work.SizesAction" method="fetchDJ">
<result name="success" type="dynamic-jasper">
<param name="dynamicReport">dr</param>
<param name="dataSource">sizeList</param>
<param name="documentName">Dynamic Report generated with struts 2</param>
<param name="parameters">params</param>
<param name="format">PDF</param>
<param name="layoutManager">classic</param>
</result>
</action>
</package>
While running this I am getting following error
There is no result type defined for type 'dynamic-jasper' mapped with name 'success'. Did you mean 'dynamicJasper'? - result - file:/E:/Project/cxn/cnx/build/web/WEB-INF/classes/struts.xml:571:58
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.buildResults(XmlConfigurationProvider.java:653)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addAction(XmlConfigurationProvider.java:387)
... 20 more
I have included following jar files
Add this configuration to your package
The
ActionSupport
class is under the package namecom.opensymphony.xwork2
. The error is occurred from the configuration of the plugin you use with Struts2 which is incompatible to the version of Struts you use.