Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Venkat Utla
CSV File Download in Liferay 4.3.5
August 28, 2012 2:59 AM

Venkat Utla

Rank: New Member

Posts: 3

Join Date: August 28, 2012

Recent Posts


We have a requirement that we need to export data into CSV file and allow the client to download the CSV file.
We have used the following code.This was writing the content of CSV file in portlet. We want it to display the a dialog box which asks the user to save or download.

Could you please let us the solution for this?

Thanks in advance.


public ActionForward render(ActionMapping mapping, ActionForm form,
PortletConfig config, RenderRequest req, RenderResponse res)
throws Exception {"SubmitSearchForReportsAction, render, starts");
req.setAttribute("csvFileData", "a,b,c");
try {
HttpServletResponse response = PortalUtil.getHttpServletResponse(res);

PrintWriter p =res.getWriter ();
StringTokenizer rt = new StringTokenizer("a,b,c;d,e,f",";");
String rowToken = null;
while (rt.hasMoreTokens()) {
rowToken = rt.nextToken();
} catch (Exception e) {
SessionErrors.add(req, e.getClass().getName());
setForward(req, ActionConstants.COMMON_NULL);
}"SubmitSearchForReportsAction, render, ends");
return mapping.findForward(Constants.ACTION_SUCCESS);