KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > taglib > CewolfPieDataTag


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/taglib/CewolfPieDataTag.java,v 1.2 2005/02/18 11:46:15 hkollmann Exp $
3  * $Revision: 1.2 $
4  * $Date: 2005/02/18 11:46:15 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */

23
24 package org.dbforms.taglib;
25
26 import java.util.HashMap JavaDoc;
27
28 import javax.servlet.jsp.JspException JavaDoc;
29
30 import de.laures.cewolf.taglib.DataAware;
31 import de.laures.cewolf.DatasetProducer;
32
33 import org.jfree.data.general.DefaultPieDataset;
34
35 import org.dbforms.util.CewolfDatasetProducer;
36 import org.dbforms.config.ResultSetVector;
37
38 /**
39  * Tag &lt;producer&gt; which defines a DatasetProducer.
40  * @see DataTag
41  * @author Guido Laures
42  */

43 public class CewolfPieDataTag extends DbBaseHandlerTag {
44     private String JavaDoc categoryField;
45     private String JavaDoc dataField;
46     
47
48     public int doEndTag() throws JspException JavaDoc {
49         DefaultPieDataset ds = new DefaultPieDataset();
50         ResultSetVector rsv = getParentForm().getResultSetVector();
51         for (int i = 0; i < rsv.size(); i++) {
52             Comparable JavaDoc c = (Comparable JavaDoc) rsv.getFieldAsObject(i, getCategoryField());
53             Number JavaDoc n = (Number JavaDoc) rsv.getFieldAsObject(i, getDataField());
54             ds.setValue(c, n);
55         }
56         DatasetProducer dataProducer = new CewolfDatasetProducer(ds);
57         DataAware dw = (DataAware) findAncestorWithClass(this, DataAware.class);
58         dw.setDataProductionConfig(dataProducer, new HashMap JavaDoc(), false);
59         return SKIP_BODY;
60     }
61
62
63     /**
64      * @return Returns the categoryField.
65      */

66     public String JavaDoc getCategoryField() {
67         return categoryField;
68     }
69     /**
70      * @param categoryField The categoryField to set.
71      */

72     public void setCategoryField(String JavaDoc categoryField) {
73         this.categoryField = categoryField;
74     }
75     /**
76      * @return Returns the dataField.
77      */

78     public String JavaDoc getDataField() {
79         return dataField;
80     }
81     /**
82      * @param dataField The dataField to set.
83      */

84     public void setDataField(String JavaDoc dataField) {
85         this.dataField = dataField;
86     }
87 }
88
Popular Tags