JSF Chart Creator Component Based on JFreeChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
cagatay_civici
Posts: 54
Joined: Sun Aug 28, 2005 8:13 pm

JSF Chart Creator Component Based on JFreeChart

Post by cagatay_civici » Sun Aug 28, 2005 8:33 pm

Hi all,

I have created a jsf component based on jfreechart api. The component is reusable and easy to install. It can create various kinds of charts easily in a few seconds after you give the attributes like background color, labels, datasource, title, orientation and etc. Here are some screenshots of my jsf component.

Here is the configuration shot from WSAD ide.

Image
Image
Image
Image


david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Sep 01, 2005 11:43 am

Thanks. Do you have a web page with project details? If so, I can provide a link on the JFreeChart home page.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Guest

Post by Guest » Thu Sep 01, 2005 8:12 pm

Hi,

The link is;

http://sourceforge.net/projects/jsfchart

Regards,

[/url]

Rasman
Posts: 5
Joined: Thu Sep 22, 2005 3:35 pm

ChartCreator

Post by Rasman » Thu Sep 22, 2005 3:40 pm

Hi

Downloaded the component and installed as per the instructions.

Defined the datasource for the compenent as;

datasource="#{someBean.dataSource}".

When I ran the app to test a basic line chart I got an empty line chart with no data. The dataSource in the bean was never accessed.

Would welcome your thoughts.

Regards

cagatay_civici
Posts: 54
Joined: Sun Aug 28, 2005 8:13 pm

Post by cagatay_civici » Fri Sep 23, 2005 7:45 pm

Hi, are you sure that the getter of the source is never accessed. Maybe it is a problem related with the value binding.Does other bindings like title etc. working?

cagatay_civici
Posts: 54
Joined: Sun Aug 28, 2005 8:13 pm

Post by cagatay_civici » Sat Sep 24, 2005 4:15 pm

Another thing, are you sure there is a getter for the source in the managed bean.

bsun_98

Post by bsun_98 » Mon Sep 26, 2005 4:11 pm

I got the same problem. I have getter method in the managed bean. But the
getter method never gets invoked. I am wondering whether anybody can
tell me where I can download the source code (bean, jsp file, faces-config.xml and web.xml) for the sample application. The charts
on the sample application look really nice.

Thanks.

Bruce

cagatay_civici
Posts: 54
Joined: Sun Aug 28, 2005 8:13 pm

Post by cagatay_civici » Mon Sep 26, 2005 4:56 pm

It looks like there is an issue with these empty charts, soon I will post a sample example or a war file to show the usage of the component.For now; if the binding is something like then you must have defined;
datasource="#{someBean.dataSource}"

public DataSourceType getDataSource() {} in your managed bean. And the datasource type must be either DefaultCategoryDataet or DefaultPieDataset.You can see the manual in the rar file.

Guest

Post by Guest » Tue Sep 27, 2005 4:04 pm

Hi

I had coded as per the manual.

My jsp looks like:

Code: Select all

<%@taglib uri="/WEB-INF/tld/chartCreator.tld" prefix="c" %>
.....
.....
<h:panelGroup id="PGpPie" rendered="true">
    <c:chartCreator id="cc1" title="Pie Chart Report" datasource="#{reportBean.source}" type="pie" background="white">
    </c:chartCreator>
</h:panelGroup>
....
....

Everything else on the jsp works.

In my backing bean I have:

Code: Select all

	public DefaultPieDataset getSource() {
		System.out.println("INSIDE ReportBean.getSource()");
		DefaultPieDataset pieSource = new DefaultPieDataset();
        pieSource.setValue("A",52);
        pieSource.setValue("B",30);
        pieSource.setValue("C",18);
        return pieSource;
    }
When I run the application and load the page I do not get any image. I have both debugged the getSource() method and put in a System.out.println() to check the method is invoked. The debugger does not stop and for the sysout no output is provided.

If the report title is fixed text that is displayed. I changed this to a value binding on the title attribute but this does not invoke the method either and no text was displayed.

Looking at the source of the loaded page the image take for the chart place holder is:

<IMG SRC="/BetterCollections/servlet/ChartWriter" BORDER=1 WIDTH=400 HEIGHT=300/>

I hope this helps.

Cheers
Seamus

Rasman
Posts: 5
Joined: Thu Sep 22, 2005 3:35 pm

Forgot to log in

Post by Rasman » Tue Sep 27, 2005 4:08 pm

Hi

Sorry, forgot to log in so previous post is mine.

Regards
Seamus

cagatay_civici
Posts: 54
Joined: Sun Aug 28, 2005 8:13 pm

Problem Solved

Post by cagatay_civici » Tue Sep 27, 2005 6:24 pm

Hi,

In the manual I wrote a mistake, the configuration;

Code: Select all

    <servlet>
        <servlet-name>ChartWriter</servlet-name>
        <servlet-class>chartcreator.ChartWriter</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>ChartWriter</servlet-name>
        <url-pattern>/servlet/ChartWriter</url-pattern>
    </servlet-mapping>
must be in web.xml not in faces-config.xml as the manual states.

ChartWriter is a simple servlet that generates the chart, the only thing the component does is to write the <img> tag as you wrote before.The servlet takes care of it later.If the img tag is printed than there is a problem with the servlet, are you sure that the config part above is in web.xml not in faces-config.xml.

Rasman
Posts: 5
Joined: Thu Sep 22, 2005 3:35 pm

Servlet mapping.

Post by Rasman » Tue Sep 27, 2005 8:53 pm

Hi

Yes the servlet mappings are in web.xml.

I realised there was a mistake in the manual when I read it and so had put the servlet mappings into web.xml not faces-config.xml before raising the issue.

So I am afraid that is not the cause of this problem.

I cut and paste the following into the faces-config.xml from the manual.

Code: Select all

<component>
      <component-type>chartCreator</component-type>
      <component-class>chartcreator.UICharter</component-class>
    </component>
Cheers
Seamus

I cut and paste the following into the web.xml from the manual.

Code: Select all

    <servlet>
        <servlet-name>ChartWriter</servlet-name>
        <servlet-class>chartcreator.ChartWriter</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>ChartWriter</servlet-name>
        <url-pattern>/servlet/ChartWriter</url-pattern>
    </servlet-mapping> 

Rasman
Posts: 5
Joined: Thu Sep 22, 2005 3:35 pm

Post by Rasman » Tue Sep 27, 2005 8:58 pm

Hi

The only other thing I can think of is that I am using
  • MyFaces (Version 1.1.0) reference implementation of JSF
    JDK 1.5
    Tomcat 5.5.9
    Windows XP.
Seamus

cagatay_civici
Posts: 54
Joined: Sun Aug 28, 2005 8:13 pm

Post by cagatay_civici » Tue Sep 27, 2005 9:56 pm

Hi, I have created and tested the component in IBM's implementation in WSAD not myFaces, JDK 1.4, TOMCAT 5.x, XP. I think that may be related with myFaces, I am not sure.Let me test it with myFaces.

Locked