vishalmali Posted March 15, 2010 Share Posted March 15, 2010 Hi,i am new to Dynamic jasper. Iam using dynamicjasper 3.0.16, can anybody please tell me how to make a grand total of particular column and give hyperlink to particular element??? One more thing I am very surprised that newer versions jars are not compatible for older versions and there are many changes in newer versions eg. names of classes are changed,anyway can please anybody help me out???Thanks in advance!!!Here is my codeCode:package com.kpit.dynamicjasper; import java.util.Date; import java.util.HashMap; import java.util.Map; import java.sql.DriverManager; import java.sql.Connection; import ar.com.fdvs.dj.core.DJConstants; import ar.com.fdvs.dj.core.DynamicJasperHelper; import ar.com.fdvs.dj.core.layout.ClassicLayoutManager; import ar.com.fdvs.dj.domain.DJHyperLink; import ar.com.fdvs.dj.domain.StringExpression; import ar.com.fdvs.dj.domain.hyperlink.LiteralExpression; import ar.com.fdvs.dj.domain.DynamicReport; import ar.com.fdvs.dj.domain.ColumnProperty;import ar.com.fdvs.dj.domain.DJCalculation; import ar.com.fdvs.dj.domain.entities.columns.OperationColumn; import ar.com.fdvs.dj.domain.entities.columns.AbstractColumn; import ar.com.fdvs.dj.domain.entities.DJGroup; import ar.com.fdvs.dj.domain.entities.columns.PropertyColumn; import ar.com.fdvs.dj.domain.builders.FastReportBuilder; import ar.com.fdvs.dj.domain.builders.DynamicReportBuilder; import ar.com.fdvs.dj.domain.builders.GroupBuilder; import ar.com.fdvs.dj.domain.builders.ColumnBuilder; import ar.com.fdvs.dj.test.BaseDjReportTest; import ar.com.fdvs.dj.test.ReportExporter; import net.sf.jasperreports.engine.xml.JRXmlWriter; import net.sf.jasperreports.view.JasperViewer; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; public class Demo{ private static Map params = new HashMap(); public static void main(String args[]) throws ClassNotFoundException, Exception{ Connection con = createSQLConnection(); DynamicReportBuilder drb = new DynamicReportBuilder(); drb.setTitle("Customer Report") //defines the title of the report .setSubtitle("This report generated at" + new Date()) .setDetailHeight(15) //defines the height for each record of the report .setMargins(30, 20, 30, 15) //define the margin space for each side (top, bottom, left and right) .setQuery("select * from customer where cust_name like $P{start}", DJConstants.QUERY_LANGUAGE_SQL) //.setQuery("select * from customer", DJConstants.QUERY_LANGUAGE_SQL) //.setDefaultStyles(titleStyle, subtitleStyle, headerStyle, detailStyle) .setColumnsPerPage(1); //defines columns per page (like in the telephone guide) AbstractColumn columnId = ColumnBuilder.getNew() //creates a new instance of a ColumnBuilder .setColumnProperty("cust_id", String.class.getName()) //defines the field of the data source that this column will show, also its type .setTitle("Id") //the title for the column .setWidth(85) //the width of the column .build(); AbstractColumn columnName = ColumnBuilder.getNew() //creates a new instance of a ColumnBuilder .setColumnProperty("cust_name", String.class.getName()) //defines the field of the data source that this column will show, also its type .setTitle("Name") //the title for the column .setWidth(85) //the width of the column .build(); AbstractColumn columnAddress = ColumnBuilder.getNew() //creates a new instance of a ColumnBuilder .setColumnProperty("cust_address", String.class.getName()) //defines the field of the data source that this column will show, also its type .setTitle("Address") //the title for the column .setWidth(85) //the width of the column .build(); AbstractColumn columnSalary = ColumnBuilder.getNew() //creates a new instance of a ColumnBuilder .setColumnProperty("cust_salary", String.class.getName()) //defines the field of the data source that this column will show, also its type .setTitle("Salary") //the title for the column .setWidth(85) //the width of the column .build();//===============Total================================= // GroupBuilder gb1 = new GroupBuilder();// DJGroup djg = gb1.setCriteriaColumn((PropertyColumn)columnSalary).build();//// drb.addGroup(djg); //add the group to the DynamicReportBuilder// GroupBuilder gb1 = new GroupBuilder();// DJGroup g1 = gb1.addFooterVariable(columnSalary,DJCalculation.SUM) //tell the group place a variable in the footer// .build(); //of the column "columnAmount" with the SUM of all// //values of the columnAmount in this group.////// drb.addGroup(g1);//===============End of Total================================= drb.addColumn(columnId); drb.addColumn(columnName); drb.addColumn(columnAddress); drb.addColumn(columnSalary); //===============HyperLink================================= DJHyperLink djlink = new DJHyperLink(); djlink.setExpression(new StringExpression() { public Object evaluate(Map fields, Map variables, Map parameters) { return "http://www.kpitcummins.com?param=" + variables.get("REPORT_COUNT"); } }); djlink.setTooltip(new LiteralExpression("I'm a literal tootltip")); drb.getColumn(2).setLink(djlink); //===============End of HyperLink================================= drb.setUseFullPageWidth(true); //we tell the report to use the full width of the page. this rezises //the columns width proportionally to meat the page width. DynamicReport dr = drb.build(); //Finally build the report! params.put("start", "a%"); JasperPrint jp = DynamicJasperHelper.generateJasperPrint(dr, new ClassicLayoutManager(), con,params ); JasperViewer.viewReport(jp); //finally display the report report } public static Connection createSQLConnection() throws Exception { Connection con = null; Class.forName("com.mysql.jdbc.Driver" ); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/icat", "root", "root"); return con; }} Link to comment Share on other sites More sharing options...
Teodor Danciu Posted March 15, 2010 Share Posted March 15, 2010 Hi, This is the wrong forum. You should post your questions on the DynamicJasper project forums at:http://dj.fdvsolutions.com/forums/ Thank you,Teodor Link to comment Share on other sites More sharing options...
vishalmali Posted March 17, 2010 Author Share Posted March 17, 2010 Thanks Teodor!!!for your reply,Actually I have posted my query to DynamicJapser forum before I posted it on japserforge forum, but still I didnt get any reply. I have posted the same query on number of forums but I didnt get any reply from any forum, so could you please suggest me any forum, from where I can get its solution?Thanks,Vishal 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