Example usage for org.jfree.chart.servlet ChartDeleter addChart

List of usage examples for org.jfree.chart.servlet ChartDeleter addChart

Introduction

In this page you can find the example usage for org.jfree.chart.servlet ChartDeleter addChart.

Prototype

public void addChart(String filename) 

Source Link

Document

Add a chart to be deleted when the session expires

Usage

From source file:com.portalbook.charting.PortletUtilities.java

/**
 * Adds a ChartDeleter object to the session object with the name JFreeChart_Deleter
 * if there is not already one bound to the session and adds the filename to the
 * list of charts to be deleted./*from ww w .  j a v  a2  s.  c  om*/
 *
 * @param tempFile  the file to be deleted.
 * @param session  the portlet session of the client.
 */
protected static void registerChartForDeletion(File tempFile, PortletSession session) {

    //  Add chart to deletion list in session
    if (session != null) {
        ChartDeleter chartDeleter = (ChartDeleter) session.getAttribute("JFreeChart_Deleter",
                PortletSession.APPLICATION_SCOPE);
        if (chartDeleter == null) {
            chartDeleter = new ChartDeleter();
            session.setAttribute("JFreeChart_Deleter", chartDeleter, PortletSession.APPLICATION_SCOPE);
        }
        chartDeleter.addChart(tempFile.getName());
        System.out.println(tempFile.getName());
    } else {
        System.out.println("Session is null - chart will not be deleted");
    }
}