1 23 24 package org.dbforms.taglib; 25 26 import java.util.HashMap ; 27 28 import javax.servlet.jsp.JspException ; 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 43 public class CewolfPieDataTag extends DbBaseHandlerTag { 44 private String categoryField; 45 private String dataField; 46 47 48 public int doEndTag() throws JspException { 49 DefaultPieDataset ds = new DefaultPieDataset(); 50 ResultSetVector rsv = getParentForm().getResultSetVector(); 51 for (int i = 0; i < rsv.size(); i++) { 52 Comparable c = (Comparable ) rsv.getFieldAsObject(i, getCategoryField()); 53 Number n = (Number ) 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 (), false); 59 return SKIP_BODY; 60 } 61 62 63 66 public String getCategoryField() { 67 return categoryField; 68 } 69 72 public void setCategoryField(String categoryField) { 73 this.categoryField = categoryField; 74 } 75 78 public String getDataField() { 79 return dataField; 80 } 81 84 public void setDataField(String dataField) { 85 this.dataField = dataField; 86 } 87 } 88 | Popular Tags |