You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by aretobios <jk...@proton.gr> on 2007/07/10 15:43:26 UTC

Jasper plugin

I have created some reports with iReport and I tried to integrated them with
my struts2 web application. While the documentation for the jasperReport
plugin explains how to use a datasource and a compiled template to generate
a report, I wasn't able to find out how to use a database connection as a
datasource and how to pass parameters to the report.

Is there any way to pass parameters from an action?

Can I use a connection from a connection pooling as a datasource?

To overcome these problems I changed the source code of the plug-in.jkoutr@
-- 
View this message in context: http://www.nabble.com/Jasper-plugin-tf4055930.html#a11521166
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Jasper plugin

Posted by aretobios <jk...@proton.gr>.
Thanx for your detailed reply.

What I did was to add the following fragment of code in the
JasperReportResult.java of the jasperReport-plugin

.
.
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(systemId);

/**
* Edited
*/
JRParameter []reportParameters = jasperReport.getParameters();
for(int i=0; i<reportParameters.length; i++){
      if(!reportParameters[i].isSystemDefined()){
           parameters.put(reportParameters[i].getName(),
stack.findValue(reportParameters[i].getName()));
      }
}
.
.

It checks whether there are non System defined parameters. If parameters
exist it assigns values from the value stack. Thus, I have to set the
parameters in the action and set names that are the same with the report
parameters (e.g. I had a jasper parameter named referenceNumber and a
setter/getter in my action for the referenceNumber variable)



Chad S. Lauritsen wrote:
> 
> Sure. I've attached an action that will allow you to use jasperreports 
> to write to the output stream. You'll have to tweak the classpath. Mine 
> probably won't work. It will load, compile and cache jrxml files located 
> in /WEB-INF/reports. It uses a javax.sql.DataSource from JNDI. It also 
> will take request parameters and translate them into java objects in 
> order to pass into the JasperReports engine.
> 
> 
> 
> aretobios wrote:
>> I have created some reports with iReport and I tried to integrated them
>> with
>> my struts2 web application. While the documentation for the jasperReport
>> plugin explains how to use a datasource and a compiled template to
>> generate
>> a report, I wasn't able to find out how to use a database connection as a
>> datasource and how to pass parameters to the report.
>>
>> Is there any way to pass parameters from an action?
>>
>> Can I use a connection from a connection pooling as a datasource?
>>
>> To overcome these problems I changed the source code of the
>> plug-in.jkoutr@
>>   
> 
> -- 
> Chad S. Lauritsen
> Ecommerce Enterprise Developer
> The Sherwin-Williams Company
> 216-566-2166
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 

-- 
View this message in context: http://www.nabble.com/Jasper-plugin-tf4055930.html#a11522386
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Jasper plugin

Posted by "Chad S. Lauritsen" <ch...@sherwin.com>.
Sure. I've attached an action that will allow you to use jasperreports 
to write to the output stream. You'll have to tweak the classpath. Mine 
probably won't work. It will load, compile and cache jrxml files located 
in /WEB-INF/reports. It uses a javax.sql.DataSource from JNDI. It also 
will take request parameters and translate them into java objects in 
order to pass into the JasperReports engine.



aretobios wrote:
> I have created some reports with iReport and I tried to integrated them with
> my struts2 web application. While the documentation for the jasperReport
> plugin explains how to use a datasource and a compiled template to generate
> a report, I wasn't able to find out how to use a database connection as a
> datasource and how to pass parameters to the report.
>
> Is there any way to pass parameters from an action?
>
> Can I use a connection from a connection pooling as a datasource?
>
> To overcome these problems I changed the source code of the plug-in.jkoutr@
>   

-- 
Chad S. Lauritsen
Ecommerce Enterprise Developer
The Sherwin-Williams Company
216-566-2166