[jboss-user] [JBoss Seam] - Re: Charts

jknotzke do-not-reply at jboss.com
Thu Aug 2 15:15:38 EDT 2007


   Here's my code:

   chartProcessor.xhtml


  | <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  |                              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  | <ui:composition xmlns="http://www.w3.org/1999/xhtml"
  |                 xmlns:s="http://jboss.com/products/seam/taglib"
  |                 xmlns:ui="http://java.sun.com/jsf/facelets"
  |                 xmlns:f="http://java.sun.com/jsf/core"
  |                 xmlns:h="http://java.sun.com/jsf/html"
  |                 xmlns:rich="http://richfaces.ajax4jsf.org/rich"
  |                 template="layout/template.xhtml">
  | 
  | <ui:define name="body">
  | 
  |     <h:messages globalOnly="true" styleClass="message"/>
  | 
  |     <h:form id="chartProcessorForm">
  | 
  |         <rich:panel>
  |             <f:facet name="header">chartProcessor</f:facet>
  | 
  |             <s:decorate id="nameDecoration" template="layout/edit.xhtml">
  |                 <s:graphicImage value="#{chartprocesserHome.chart}" />
  |             </s:decorate>
  | 
  |             <div style="clear:both"/>
  | 
  |         </rich:panel>
  | 
  |         <div class="actionButtons">
  |             <h:commandButton id="save"
  |                           value="Save"
  |                          action="#{chartProcessorHome.persist}"
  |                        rendered="#{!chartProcessorHome.managed}"/>
  |             <h:commandButton id="update"
  |                           value="Save"
  |                          action="#{chartProcessorHome.update}"
  |                        rendered="#{chartProcessorHome.managed}"/>
  |             <h:commandButton id="delete"
  |                           value="Delete"
  |                          action="#{chartProcessorHome.remove}"
  |                        rendered="#{chartProcessorHome.managed}"/>
  |             <s:button propagation="end"
  |                                id="done"
  |                             value="Done"
  |                              view="/chartProcessorList.xhtml"/>
  |         </div>
  | 
  |     </h:form>
  | 
  | </ui:define>
  | 
  | </ui:composition>
  | 

  And ChartProcessor.java


  | package com.techsolcom.powermanager;
  | 
  | import java.io.IOException;
  | import java.io.Serializable;
  | 
  | import javax.persistence.Entity;
  | import javax.persistence.EntityManager;
  | 
  | import org.jboss.seam.annotations.Factory;
  | import org.jboss.seam.annotations.In;
  | import javax.persistence.Id;
  | import org.jboss.seam.annotations.Name;
  | import org.jfree.chart.ChartFactory;
  | import org.jfree.chart.ChartUtilities;
  | import org.jfree.chart.JFreeChart;
  | import org.jfree.chart.plot.PlotOrientation;
  | import org.jfree.data.category.DefaultCategoryDataset;
  | import org.jfree.data.xy.XYSeries;
  | import org.jfree.data.xy.XYSeriesCollection;
  | import org.hibernate.validator.NotNull;
  | 
  | @Entity
  | public class ChartProcessor implements Serializable
  | {
  |     byte[] chart;
  | 
  |     @Factory("chart")
  |     public void createChart()
  |     {
  | 
  |          System.out.println("Trying to create a FREAKING CHART!!");
  | 
  |          XYSeries series = new XYSeries("XYGraph");
  |          series.add(1, 1);
  |          series.add(1, 2);
  |          series.add(2, 1);
  |          series.add(3, 9);
  |          series.add(4, 10);
  |          //         Add the series to your data set
  |          XYSeriesCollection dataset = new XYSeriesCollection();
  |          dataset.addSeries(series);
  |          //         Generate the graph
  |          JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", // Title
  |                  "x-axis", // x-axis Label
  |                  "y-axis", // y-axis Label
  |                  dataset, // Dataset
  |                  PlotOrientation.VERTICAL, // Plot Orientation
  |                  true, // Show Legend
  |                  true, // Use tooltips
  |                  false // Configure chart to generate URLs?
  |              );
  | 
  |        try{
  |             this.chart = ChartUtilities.encodeAsPNG(chart.createBufferedImage(400, 400));
  |        } catch (IOException e){
  |             e.printStackTrace();
  |        }
  | 
  |   }
  | }
  | 

  All I get is a little graphic icon.. No exception.. Oh, and "         System.out.println("Trying to create a FREAKING CHART!!");" never gets executed.. at least not that I can see.

   Thanks
   J




View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070259#4070259

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4070259



More information about the jboss-user mailing list