Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Rocco Sapienza
Downloda pdf file
January 27, 2011 4:18 PM
Answer

Rocco Sapienza

Rank: New Member

Posts: 6

Join Date: November 30, 2010

Recent Posts

Hi,
I'm developing a personal jsf (v 1.2) + richfaces (v3.3.3) portlet for a web site (liferay 5.2.3 ). I have two different problem:

1. Richfaces' componet work, but I don't see the header of a panel/datatable/etc.... Why? I use the jboss portlet bridge (2.1) too

2. I create a pdf by JasperReports 3.7.6 (+ iText 2.1.7). The pdf was correct generated and I want that user can see/download it from my portlet. It's possible?? By the web nobody have done that..... :-(

Thanks

Rocco
Aritz Galdos
RE: Downloda pdf file
January 28, 2011 2:14 AM
Answer

Aritz Galdos

Rank: Expert

Posts: 396

Join Date: May 15, 2007

Recent Posts

HI Rocco:

If your portlet is portlet 2.0 specification compliant, it is usually done serving resource.

If you are extending MVCPortlet in your porltet, you can implement this method
1public void serveResource(ResourceRequest resourceRequest,
2            ResourceResponse resourceResponse) throws IOException


In which resourceResponse you can wrte the pdf file.

 1
 2public void serveResource(ResourceRequest resourceRequest,
 3            ResourceResponse resourceResponse) throws IOException,
 4            PortletException {
 5OutputStream os = resourceResponse.getPortletOutputStream();   
 6....
 7....
 8JasperExportManager.exportReportToPdfStream(print, os);
 9}


Which results in a pdf download.

For invoking this you can use this tag
1<portlet:resourceURL></portlet:resourceURL>




Hope that helps.
Hitoshi Ozawa
RE: Downloda pdf file
January 28, 2011 4:14 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Rocco Sapienza:

2. I create a pdf by JasperReports 3.7.6 (+ iText 2.1.7). The pdf was correct generated and I want that user can see/download it from my portlet. It's possible?? By the web nobody have done that..... :-(


Not sure about your question. Are you generating pdf output from JasperReport and showing it in a portlet? I really don't see the problem. The most recent Liferay 6 EE has a JasperReport portlet.

If you're interested in a more web based JasperReport system, check out JasperServer. You'll be able to schedule report generation and select and view generated reports from a web browser and download reports as pdf, excel and other formats supported by JasperReport.
Faris Abdulla
RE: Downloda pdf file
January 28, 2011 6:48 AM
Answer

Faris Abdulla

Rank: Regular Member

Posts: 183

Join Date: September 1, 2009

Recent Posts

Hi Rocco,

You can use iframe to display the pdf in your portlet. From there you will get all the normal functions to download scroll etc.
Hitoshi Ozawa
RE: Downloda pdf file
January 30, 2011 3:47 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

Faris Abdulla:
Hi Rocco,

You can use iframe to display the pdf in your portlet. From there you will get all the normal functions to download scroll etc.


In this case, you'll need to write a servlet that uses jasperreports. Just set the servlet uri as the iframe url.
Faris Abdulla
RE: Downloda pdf file
January 31, 2011 5:53 AM
Answer

Faris Abdulla

Rank: Regular Member

Posts: 183

Join Date: September 1, 2009

Recent Posts

Yes, Hitoshi you are right.
The servlet which will invoke the jasperreport for generating pdf.
Hitoshi Ozawa
RE: Downloda pdf file
January 31, 2011 1:34 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7990

Join Date: March 23, 2010

Recent Posts

I'm also involved with Jaspersoft. :-)
Attachment

Attachments: ireport.jpg (6.5k)
Rocco Sapienza
RE: Downloda pdf file
February 17, 2011 9:18 AM
Answer

Rocco Sapienza

Rank: New Member

Posts: 6

Join Date: November 30, 2010

Recent Posts

Thanks to all for reply.
I've solved my problem in other way.

1. I've created a servlet that catch the pdf file to my portlet and create a BufferedOutputStream to send to reponse
2. When user click on the button, the action simply redirect to the specific URI that I've defined in web.xml

Regards

Rocco