jvencebi Posted October 5, 2010 Share Posted October 5, 2010 Hi everybody !!! I have a master report with several subreports. In the subreport properties put the Connection expression as $P{REPORT_CONNECTION} . When the report is run in iReport both reports get data but when the master report is called from a zk controller the master gets data, the subreport does not.I found a thread with this same subject in http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=11772but when the query is deleted in the master report the subreport does not show data in iReport.Note: Since we are using zk's jasperreport tag, we had to create a class implementing JRDataSource wich receives the connection and the jasper report .Please, help me know if there is a version bug or maybe I'm doing something wrong. JuanCode: public ClassImplementingJRDataSource(Connection conn,JasperReport jasperReport,Map<String ,Object> params){ this.conn = conn; m_nIdx = -1; sql = jasperReport.getQuery().getText(); sql = sql.replaceAll("\\$P\\{infoId\\}", params.get("infoId").toString()); sql = sql.replaceAll("\\$P\\{coopType\\}", "'"+params.get("coopType").toString()+"'"); try { stmt = this.conn.createStatement(); rs = stmt.executeQuery(sql); } catch (SQLException e) { e.printStackTrace(); } } Link to comment Share on other sites More sharing options...
jvencebi Posted October 5, 2010 Author Share Posted October 5, 2010 It's alive !!! I found in another thread something to pass the connection as a parameter:parameters.put("REPORT_CONNECTION",conn);// conn is a java.sql.Connection objectand it's working now.The thread with the information is in: http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=55312See you later,JuanCode:Map<String, Object> params = new HashMap<String, Object>();params.put("SUBREPORT_DIR", urreportpathhere);params.put("SUBREPORTDATASOURCE", urdatasourcehere);JasperPrint print =JasperUtil.fillReport(mainreportpath, params, mainreportdatasource);Post Edited by jvencebi at 10/05/2010 17:47 Link to comment Share on other sites More sharing options...
bninan Posted November 26, 2010 Share Posted November 26, 2010 Code:Hi Juan, I want to add subreports to my report using java and Jasper API. Do you know how to do it? Thanks. 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