You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Phillips, Bruce A" <bp...@ku.edu> on 2008/10/27 17:50:05 UTC
Struts 2 JasperReports Plugin How to Use XML As The Data Source
I'm working on a Struts 2 web application (using Struts version 2.1.2)
that needs to take an XML file and create a PDF report. I've previously
used the Struts 2 JasperReports plugin to generate a PDF but my data
source was an ArrayList. For example see:
http://www.brucephillips.name/blog/index.cfm/2008/7/12/Using-The-JasperR
eports-Struts2-Plugin-A-Main-Report-And-A-Subreport
I've not been able to find a good example of using the Struts 2
JasperReport plugin with a data source of XML. If anyone knows of a
good example please reply.
Here is where I think I'm stuck. In my struts.xml file I have this
action defined:
<action name="myJasperTest" class="action.JasperAction">
<result name="success" type="jasper">
<param
name="location">/jasper/PeopleXMLReport.jasper</param>
<param name="dataSource">Xml</param>
<param name="format">PDF</param>
</result>
<result name="error" type="jasper">/Error.jsp</result>
</action>
The param name="dataSource" with a value of Xml does call the getXml
method in my action.JasperAction class. This method returns an object
of type org.w3c.dom.Document. But in my PDF I just get null values. So
I'm not sure what my getXML method should be returning.
Any help would be greatly appreciated.
Bruce
RE: Struts 2 JasperReports Plugin How to Use XML As The Data Source
Posted by "Phillips, Bruce A" <bp...@ku.edu>.
Torsten - That is what I ended up doing as I could not get the Struts 2 JasperReports plug-in to work with the XML data source.
Bruce
-----Original Message-----
From: Torsten Krah [mailto:tkrah@fachschaft.imn.htwk-leipzig.de]
Sent: Monday, October 27, 2008 4:53 PM
To: Struts Users Mailing List
Subject: Re: Struts 2 JasperReports Plugin How to Use XML As The Data Source
Am Montag, 27. Oktober 2008 schrieb Phillips, Bruce A:
> Any help would be greatly appreciated.
Use the stream Result of Struts2 and construct your PDF with Jasper "without
the plugin".
Take a look at the examples of JR (sourcecode included in the JR download) -
there is a good example with XML Datasource too there.
Build your pdf with JRPdfExporter and use StreamResult to get the actual
stream.
Re: Struts 2 JasperReports Plugin How to Use XML As The Data Source
Posted by Torsten Krah <tk...@fachschaft.imn.htwk-leipzig.de>.
Am Montag, 27. Oktober 2008 schrieb Phillips, Bruce A:
> Any help would be greatly appreciated.
Use the stream Result of Struts2 and construct your PDF with Jasper "without
the plugin".
Take a look at the examples of JR (sourcecode included in the JR download) -
there is a good example with XML Datasource too there.
Build your pdf with JRPdfExporter and use StreamResult to get the actual
stream.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org