primoz Posted February 3, 2010 Share Posted February 3, 2010 Hi,I need a report with javaBean datasource and generic groups.I have created a new JavaBean Datasource and the data are displayed in the report. But I do not know how to use dynamic groups with data from javabean. I have no problem with dynamic groups when the datasource is database.You can read more about dynamic group and database at http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=54915&page=2.I have done the following steps:1.create a report with javabean datasource2.add a new group with group expression $P{REPORT_SCRIPTLET}.evaluateField($P{P_GROUP_COLUMN1})3.My data is not grouped Below is EvaluationScriptlet class. Does anyone know how to modify the report for this kind of usage?Regards,Primozimport net.sf.jasperreports.engine.JRDefaultScriptlet;import net.sf.jasperreports.engine.JRScriptletException;import net.sf.jasperreports.engine.fill.JRFillField;public class EvaluationScriptlet extends JRDefaultScriptlet { public Object evaluateField(String fieldName) throws JRScriptletException { System.out.println("evaluateField=" + fieldName); JRFillField field = (JRFillField)this.fieldsMap.get(fieldName); System.out.println("field=" + field); if (field == null) { throw new JRScriptletException("Field not found : " + fieldName); } StackTraceElement[] stack = new Exception().getStackTrace(); if (stack.length < 2) { throw new JRScriptletException("Unable to obtain current call stack"); } String evaluateMethod = stack[1].getMethodName(); Object value; if (evaluateMethod.startsWith("evaluateOld")) { value = field.getOldValue(); System.out.println("evaluateOld=" + value); } else if (evaluateMethod.startsWith("evaluate")) { value = field.getValue(); System.out.println("evaluate=" + value); } else { value = field.getValue(); System.out.println("EvaluationScriptlet=" + value); //throw new JRScriptletException("Unable to determine evaluation type from method name " + evaluateMethod + ".." + fieldName + ".." + field + ".." + field.getDescription() + ".." + field.getValue() + "..." + field.getOldValue()); } return value; } public String priorityDescription() throws JRScriptletException { return ""; }} Link to comment Share on other sites More sharing options...
sousa1981 Posted February 5, 2010 Share Posted February 5, 2010 To have grouping work, you will need to order at ascending or descending. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now