Archive for the ‘Struts 2’ Category

Jasper Report, Struts 2, iReport and Maven

May 16, 2011

Step 1: Adding POM Dependency

org.apache.struts
struts2-jasperreports-plugin
2.2.1.1

Step 2: Design the “jrxml” file using iReport. You can also manually design this “jrxml”

Step 3: Struts.xml ,br/>

——-

——-

/jasper/financial_report_template.jasper
objectReportList
PDF

In Struts.xml result “type” must be jasper. “location” means where the compiled jrxmlfile will be present to
generate the report param “format” is the format in which the user is trying to export it can be PDF,XLS,CSV etc.
“datasource” as “objectReportList” the object list fed to jasper report from which the data is populated this
is present inside the action class. For example of you are trying to export “Person” details the
datasource will be “personList” this is fetched from database in Action class.

Advertisements

Struts 2, Jasperreport, iReport and Maven

April 9, 2011

Step 1: Adding POM Dependency

org.apache.struts
struts2-jasperreports-plugin
2.2.1.1

Step 2: Design the “jrxml” file using iReport. You can also manually design this “jrxml”

Step 3: Struts.xml

——-

——-

/jasper/financial_report_template.jasper
objectReportList
PDF

In Struts.xml result “type” must be jasper. “location” means where the compiled jrxmlfile will be present to
generate the report param “format” is the format in which the user is trying to export it can be PDF,XLS,CSV etc.
“datasource” as “objectReportList” the object list fed to jasper report from which the data is populated this
is present inside the action class. For example of you are trying to export “Person” details the
datasource will be “personList” this is fetched from database in Action class.

Step 4: Compiling jrxml file to jasper file
the folowing code is to be written inside your Action class

JasperCompileManager.compileReportToFile(
“D:\\locationto\\financial_report_template.jrxml”,
“D:\\locationto\\financial_report_template.jasper”);

}
After successful export you can remove the compilation code and just place the jasper file in the location
to avoid compilation of jrxml file to jasper everytime when you are exporting,br/.
specified in struts.xml

WARNING: No configuration found for the specified action: ‘ ‘ in namespace: ‘ ‘. Form action defaulting to ‘action’ attribute’s literal value

February 2, 2011

Tips:- Look at the namespace tag and the namespace add by you

Steps to resolve this warning

Step 1 ) In the default namespace added in struts.xml file, append a “/” followed by the namespace name

for the “namespace” attribute of the “package” tag “
eg:- package tag attributes :- name=”test” namespace=”/test” extends=”struts-default”

Step 2 ) In the jsp file, append a “/” followed by the namespace name

for the “namespace” attribute of “form” tag”
eg:-
form tag attributes :- action=”TestAction” namespace=”/test”