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

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

Introduction

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

Prototype

public ChartDeleter() 

Source Link

Document

Blank constructor.

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./*  w w  w. j  a va 2 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");
    }
}