001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.workplace.list; 029 030import org.opencms.jsp.CmsJspActionElement; 031import org.opencms.workplace.CmsDialog; 032 033import javax.servlet.http.HttpServletRequest; 034import javax.servlet.http.HttpServletResponse; 035import javax.servlet.jsp.PageContext; 036 037/** 038 * Generates a CSV file for a given list.<p> 039 * 040 * @since 6.0.0 041 */ 042public class CmsListCsvExportDialog extends CmsDialog { 043 044 /** List class parameter name constant. */ 045 public static final String PARAM_LISTCLASS = "listclass"; 046 047 /** List class parameter value. */ 048 private String m_paramListclass; 049 050 /** 051 * Public constructor.<p> 052 * 053 * @param jsp an initialized JSP action element 054 */ 055 public CmsListCsvExportDialog(CmsJspActionElement jsp) { 056 057 super(jsp); 058 } 059 060 /** 061 * Generates the CSV file for the given list.<p> 062 * 063 * @return CSV file 064 * 065 * @throws ClassNotFoundException if the list dialog class is not found 066 */ 067 public String generateCsv() throws ClassNotFoundException { 068 069 CmsHtmlList list = A_CmsListDialog.getListObject(Class.forName(getParamListclass()), getSettings()); 070 return list.listCsv(); 071 } 072 073 /** 074 * Public constructor with JSP variables.<p> 075 * 076 * @param context the JSP page context 077 * @param req the JSP request 078 * @param res the JSP response 079 */ 080 public CmsListCsvExportDialog(PageContext context, HttpServletRequest req, HttpServletResponse res) { 081 082 this(new CmsJspActionElement(context, req, res)); 083 } 084 085 /** 086 * Returns the value for the List class parameter.<p> 087 * 088 * @return the value for the List class parameter 089 */ 090 public String getParamListclass() { 091 092 return m_paramListclass; 093 } 094 095 /** 096 * Sets the value for the List class parameter.<p> 097 * 098 * @param listclass the value for the List class parameter to set 099 */ 100 public void setParamListclass(String listclass) { 101 102 m_paramListclass = listclass; 103 } 104 105}