Search code examples
jsfprimefacesdynamic-contentgraphicimage

WARNING: JSF1091: No mime type could be found for file dynamiccontent


I get the following warning under eclipse :

WARNING: JSF1091: No mime type could be found for file dynamiccontent. To resolve this, add a mime-type mapping to the applications web.xml

This error is caused when I post a picture

below primefaces composant :

<p:graphicImage  value="#{bean.image}"/>

Java Bean :

private StreamedContent image;

// Getter
public StreamedContent getImage() {
    try {
        JFreeChart jfreechart = ChartFactory.createPieChart3D("",
                        createDataset(), true, true, false);

        PiePlot3D plot = (PiePlot3D) jfreechart.getPlot();

        File chartFile = new File("dynamichart");
        ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 375, 300);
        chartImage = new DefaultStreamedContent(new FileInputStream(
                        chartFile), "image/png");
        return chartImage;
    } catch (Exception e) {
        e.printStackTrace();
        return new DefaultStreamedContent();
    }
}

// generate data for image
public static PieDataset createDataset() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("A",10);
    dataset.setValue("B", 11);
    dataset.setValue("C", 80);
    dataset.setValue("D", 12);
    return dataset;
}

Solution

  • I found one solution.

    by using the latest version of primefaces (3.5).

    <dependency>  
        <groupId>org.primefaces</groupId>  
        <artifactId>primefaces</artifactId>  
        <version>3.5</version>  
    </dependency> 
    

    but there will unpleasant changes in IHM