2 Replies Latest reply on Feb 10, 2009 6:01 AM by Amit Deshpande

    have any one get chartcreator to work with jboss portal?

    Kevin Du Newbie

      Hi,

      I was trying to draw a chart within a portlet in jboss
      portal with chartcreator (http://jsf-comp.sourceforge.net/components/chartcreator/index.html) but failed. the image is not
      rendering. by view source, I've got
      img id="impressions" width="400" height="300"
      src="chartcreatorrequest.jsf?ts=1154984708281&id=impressions"
      but the picture is just not drawn.


      my jsf file:

      <chart:chart id="impressions" title="Impressions"
      datasource="#{folderDailyImps}" type="timeseries"
      width="400" height="300" />

      my bean

      @Out(scope=ScopeType.SESSION, required=false)
      private TimeSeriesCollection folderDailyImps;

      @Factory("folderDailyImps")
      public void populateTimeSeries() {

      Connection conn = _session.connection();
      PreparedStatement ps = null;
      ResultSet rs = null;
      TimeSeries series = null;
      folderDailyImps = new TimeSeriesCollection();

      try {
      ps = conn.prepareStatement(SQL_GET_GOOGLE_TIME_SERIES);
      ps.setInt(1, 1);
      rs = ps.executeQuery();

      while (rs.next()) {
      if (series != null) {
      folderDailyImps.addSeries(series); // Add the last
      series
      }
      series = new TimeSeries(rs.getString("name"),
      Day.class);
      series.add(new Day(new
      Date(rs.getDate("xdate").getTime())), rs
      .getInt("imps"));
      logger.info(rs.getString("name") + " " +
      rs.getDate("xdate") + " " + rs.getInt("imps"));
      }
      logger.info("folderDailyImps factory method invoked");
      } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      }


      portlet.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <portlet-app
      xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
      version="1.0">


      <portlet-name>Reporting</portlet-name>

      <portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>
      <init-param>
      default-view
      /home.seam
      </init-param>

      <mime-type>text/html</mime-type>
      <portlet-mode>VIEW</portlet-mode>

      <portlet-info>
      Reporting
      </portlet-info>


      </portlet-app>

      porlet-instance.xml
      <?xml version="1.0"?>



      <instance-id>ReportingInstance</instance-id>
      <portlet-ref>Reporting</portlet-ref>




      portal-object.xml


      <if-exists>overwrite</if-exists>
      <parent-ref>siab</parent-ref>

      <page-name>Reporting</page-name>


      <window-name>ReportingWindow</window-name>
      <instance-ref>ReportingInstance</instance-ref>
      center
      1

      <security-constraint>
      <policy-permission>
      <role-name>Authenticated</role-name>
      <action-name>viewrecursive</action-name>
      </policy-permission>
      </security-constraint>



      any idea?

        • 1. Re: have any one get chartcreator to work with jboss portal?
          Tim McCune Novice

          Doesn't really have anything to do with JBoss Portal, but I just patched the chart creator to work inside JBoss Portal. In case anyone cares, here is the patch:

          diff --new-file -rc ./net/sf/jsfcomp/chartcreator/ChartListener.java /home/tim/src/3p/chartcreator-1.2.0-RC1/net/sf/jsfcomp/chartcreator/ChartListener.java
          *** ./net/sf/jsfcomp/chartcreator/ChartListener.java 2006-08-08 01:22:01.000000000 -0700
          --- /home/tim/src/3p/chartcreator-1.2.0-RC1/net/sf/jsfcomp/chartcreator/ChartListener.java 2006-08-08 01:17:28.000000000 -0700
          ***************
          *** 53,58 ****
          --- 53,64 ----
           Map sessionMap = externalContext.getSessionMap();
          
           String id = (String)requestMap.get("id");
          + for (Object key : sessionMap.keySet()) {
          + String s = (String) key;
          + if (s.endsWith("?" + id)) {
          + id = s;
          + }
          + }
           ChartData chartData = (ChartData) sessionMap.get(id);
           JFreeChart chart = ChartUtils.createChartWithType(chartData);
           ChartUtils.setGeneralChartProperties(chart, chartData);
          ***************
          *** 71,81 ****
           }
          
           public void beforePhase(PhaseEvent phaseEvent) {
          -
           }
          
           public PhaseId getPhaseId() {
          ! return PhaseId.RESTORE_VIEW;
           }
          
           private void writeChartWithServletResponse(HttpServletResponse response, JFreeChart chart, ChartData chartData) throws IOException{
          --- 77,86 ----
           }
          
           public void beforePhase(PhaseEvent phaseEvent) {
           }
          
           public PhaseId getPhaseId() {
          ! return PhaseId.ANY_PHASE;
           }
          
           private void writeChartWithServletResponse(HttpServletResponse response, JFreeChart chart, ChartData chartData) throws IOException{
          diff --new-file -rc ./net/sf/jsfcomp/chartcreator/UIChart.java /home/tim/src/3p/chartcreator-1.2.0-RC1/net/sf/jsfcomp/chartcreator/UIChart.java
          *** ./net/sf/jsfcomp/chartcreator/UIChart.java 2006-08-08 01:22:01.000000000 -0700
          --- /home/tim/src/3p/chartcreator-1.2.0-RC1/net/sf/jsfcomp/chartcreator/UIChart.java 2006-08-08 01:23:24.000000000 -0700
          ***************
          *** 113,119 ****
           writer.writeAttribute("id", getClientId(context), null);
           writer.writeAttribute("width", String.valueOf(getWidth()), null);
           writer.writeAttribute("height", String.valueOf(getHeight()), null);
          ! writer.writeAttribute("src", ChartListener.CHART_REQUEST + ".jsf?ts=" + System.currentTimeMillis() + "&id=" + getClientId(context), null);
           ChartUtils.renderPassThruImgAttributes(writer, this);
           }
          
          --- 113,122 ----
           writer.writeAttribute("id", getClientId(context), null);
           writer.writeAttribute("width", String.valueOf(getWidth()), null);
           writer.writeAttribute("height", String.valueOf(getHeight()), null);
          ! writer.writeAttribute("src", context.getApplication().getViewHandler().getResourceURL(context, "/") +
          ! ChartListener.CHART_REQUEST + ".jsf?ts=" + System.currentTimeMillis() +
          ! "&id=" + getClientId(context), null);
          !
           ChartUtils.renderPassThruImgAttributes(writer, this);
           }
          


          • 2. Re: have any one get chartcreator to work with jboss portal?
            Amit Deshpande Newbie

            Hi,

            I tried your patch, but I am still not able to get chart image on the portlet. Can you please share your code or if any other setting / configuration that you have done? This will be of great help. By the way I am using Websphere Portal Server 6.1. Thanks in advance,

            Regards,

            Amit