I had some similar issues and I solved them by upgrading the JasperReports
from 2.x to 3.0.0.




novotny wrote:
> 
> Hi,
> 
> Ok I found in wicketstuff, a JRPdfResource  class that does the jasper to
> pdf conversion for me
> and I added code to do this:
> 
> InputStream is = getClass().getResourceAsStream("/test.jasper");
> 
>         JRResource pdfResource = new JRPdfResource(is);
> 
>         pdfResource.setReportParameters(new HashMap<String, Object>());
>         add(new ResourceLink("print", pdfResource));
> 
> But when I run it I get 
> 
> org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException:
> Unable to serialize class: java.io.ByteArrayInputStream
> Field hierarchy is:
>   2 [class=com.homeaccount.web.loanoptions.MortgageResultsPage, path=2]
>     private java.lang.Object org.apache.wicket.MarkupContainer.children
> [class=[Ljava.lang.Object;]
>       private java.lang.Object
> org.apache.wicket.MarkupContainer.children[8]
> [class=org.apache.wicket.markup.html.link.ResourceLink, path=2:print]
>         private final org.apache.wicket.Resource
> org.apache.wicket.markup.html.link.ResourceLink.resource
> [class=com.homeaccount.web.jasper.JRPdfResource]
>           private
> com.homeaccount.web.jasper.JRResource$JasperReportFactory
> com.homeaccount.web.jasper.JRResource.jasperReportFactory
> [class=com.homeaccount.web.jasper.JRResource$1]
>             final java.io.InputStream
> com.homeaccount.web.jasper.JRResource$1.val$report
> [class=java.io.ByteArrayInputStream] <----- field that is not serializable
>       at
> org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:349)
>       at
> org.apache.wicket.util.io.SerializableChecker.checkFields(SerializableChecker.java:618)
>       at
> org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:541)
> 
> I checked and JRResources implements Serializable, is there a way I can
> get Wicket to avoid serializing this?
> 
> I was also thinking maybe I could do something like this:
> 
> add(new Link("print") {
> 
> 
>             public void onClick() {
>                 InputStream is =
> getClass().getResourceAsStream("/test.jasper");
>                 JRResource pdfStream = new JRPdfResource(is);
>                 pdfStream.setReportParameters(new HashMap<String,
> Object>());
>                 getRequestCycle().setRequestTarget(new
> ResourceStreamRequestTarget(pdfStream).setFileName("test.pdf"));
>             }
>         });
> 
> But turns out JRResource extends DynamicWebResource and does not implement
> IResourceStream so not sure if this can be made to work...
> 
> Thanks, Jason
> 
> 
> Pills wrote:
>> 
>> Hi,
>> 
>> look at RequestCycle#setRequestTarget and ResourceStreamRequestTarget
>> 
>> 
>> novotny wrote:
>>> Hi,
>>>
>>> I'm learning Jasper to create/display a PDF when a link is clicked and
>>> the
>>> template code I have looks like:
>>>
>>> ServletOutputStream servletOutputStream = response.getOutputStream();
>>>         InputStream reportStream =
>>> getServletConfig().getServletContext().getResourceAsStream("/reports/FirstReport.jasper");
>>>       
>>>             JasperRunManager.runReportToPdfStream(reportStream,
>>>                     servletOutputStream, new HashMap(), new
>>> JREmptyDataSource());
>>>
>>>             response.setContentType("application/pdf");
>>>             servletOutputStream.flush();
>>>             servletOutputStream.close();
>>>
>>> How should I acccess the servlet objects, or is there a better way to do
>>> this that is the "wicket way(tm)"?
>>>
>>> Much appreciated, Jason
>>>        
>>>   
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>> For additional commands, e-mail: users-h...@wicket.apache.org
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/access-ServletOutputStream-in-wicket-tp21487704p21493497.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to