Jump to content
We've recently updated our Privacy Statement, available here ×

pvradhakrishna

Members
  • Posts

    13
  • Joined

  • Last visited

pvradhakrishna's Achievements

Apprentice

Apprentice (3/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. Wondering why the iReports Field class type choice in Field properties tab for any of the Java data, especially for primitive data types is always its wrapper class equivalent. For example, I would using java.lang.Long for a long data type and so on.. Shouldn't I be having an option to choose a primitive type because I always saw that a choice of Wrapper class type for all fields results in a loss of performance, is there a way to choose primitive field types ? Thanks Krishna Post Edited by radha proddaturi at 03/16/09 18:20
  2. Wondering why the iReports Field class type choice in Field properties tab for any of the Java data, especially for primitive data types is always its wrapper class equivalent. For example, I would using java.lang.Long for a long data type and so on.. Shouldn't I be having an option to choose a primitive type because I always saw that a choice of Wrapper class type for all fields results in a loss of performance, is there a way to choose primitive field types ? Thanks Krishna
  3. Could you post your class and the method that pumps the pdf to the response or how have you fixed it!
  4. Hey dude, I found that the examples provided in the link: http://sourceforge.net/project/showfiles.php?group_id=36382&package_id=28579&release_id=600358 they provide two different ways of getting the sub-reports done! I think either of them will solve your problem. Let me know if you still are unable to solve this. Post your jrxml and code and we can figure out the problem. Regards Krishna
  5. I would really appreciate if you guys amirage_m_b and dima_toxsoft post example code with as much detail as possible or post as an attachment. Looking forward for the example source!!! Thanks Krishna Post edited by: pvradhakrishna, at: 2008/06/25 14:24
  6. Interestingly, I could not find a location or have any idea how to make ireport to accept any other .cfg.xml file name other than "hibernate.cfg.xml" file. Many have their own cfg.xml files in place. Wonder how we can request ireport to change the cfg.xml files default name. Right now I am trying to follow its convention by creating yet another hibernate.cfg.xml for temporary usage!
  7. Its been a while I have been using Jasper Reports. Almost all of the posts here discuss Jasper reports that are created using data sources from database connection or queries, csv, xml or other data sources. Every report that I have created uses java collection or array based data sources which are passed from an external program/class as an array or collection as most of the fields are calculated and as sql queries cannot be used!!! This is how I have been able to pass my collection as an array to create my jasper report. Code:JasperReport jasperReport = JasperCompileManager.compileReport(fileName); HashMap<String, String> hmapParam = new HashMap<String, String>(); hmapParam.put("someKey", "someValue"«»); ... JasperPrint print = JasperFillManager.fillReport(jasperReport, hmapParam, new JRBeanArrayDataSource(someArrayFromAList)); JasperExportManager.exportReportToPdfFile(print, pathName + "Report.pdf"); // or JasperViewer.viewReport(print, false); The field names defined in the report jrxml allow me to iterate specific fields/properties on a collection to show the java collection or array datasource (array of objects with getter and setters) as a table in the report. However, often there are cases where I have to show more than one collection in the same report ie., I now have a collection object as a field. This scenario is similar to the sub-report, however, the only difference being that my sub-report is populated using another collection and not from any other data source. When I try creating a sub report in the parent and populate the child report with its new collection separately and then followed by the parent with its own collection, I only see that the parent report alone is created with an empty child report. However, I see that both parent and child reports individually generate their report pdf files. Code:[code]String mainRptName = "mainRpt.jrxml"; String subRptName = "subRpt.jrxml"; String pathName = getServlet().getServletContext().getRealPath("/")+"pages\reports\"; String mainRptFileName = pathName + mainRptName; String subRptFileName = pathName + subRptName; hmapParam.put("SUBREPORT_DIR", pathName); JasperReport jasperSubReport = JasperCompileManager.compileReport(subRptFileName); JasperCompileManager.compileReportToFile(subRptFileName); JasperPrint subRptprint = JasperFillManager.fillReport(jasperSubReport, hmapParam,new JRBeanArrayDataSource(subRptList.toArray())); JasperReport jasperMainReport = JasperCompileManager.compileReport(mainRptFileName); JasperPrint mainRptPrint = JasperFillManager.fillReport(jasperMainReport, hmapParam, new JRBeanArrayDataSource(mainRptList.toArray())); JasperViewer.viewReport(mainRptPrint, false); How can I send a collection to a sub-report as I don't see an option in the jrxml fields or how can I iterate a collection if available for an object in the jrxml. I know we can access other parent objects fields as childObj.parentObj.field to display in case you have a parentObj field in the jrxml where you pass an array/collection of childObj to the jrxml. Any suggestions or comments. Thanks Krishna Post edited by: pvradhakrishna, at: 2008/06/24 05:03 Post edited by: pvradhakrishna, at: 2008/06/24 05:04 Post edited by: pvradhakrishna, at: 2008/06/24 05:08 Post edited by: pvradhakrishna, at: 2008/06/24 05:09 Post edited by: pvradhakrishna, at: 2008/06/24 15:37
  8. I solved this by passing a hashmap parameter parameters.put("SUBREPORT_DIR", "actual path to the subreport.jasper file location" ); should also end with a '', don't forget escape characters '' if you are hard-coding the path rather than use a file.getAbosolutePath() or something.. You have to mention in the subReport.jasper location correctly. First check by opening in i-report the subReport.jrxml report properties to see if the name matches with the correct name, for example, "childReport" given in the parentReport.jrxml's subReport location/expression as $P{SUBREPORT_DIR} + "childReport.jasper" Make sure that the child is compiled to a ".jasper" before running your parent. Do a quick search if you cannot find it. If you don't know how to do that let me know!!!
  9. I solved this by passing a hashmap parameter parameters.put("SUBREPORT_DIR", "actual path to the subreport.jasper file location" ); should also end with a backslash , don't forget escape characters '' if you are hard-coding the path rather than use a file.getAbosolutePath() or something.. You have to mention in the subReport.jasper location correctly. First check by opening in i-report the subReport.jrxml report properties to see if the name matches with the correct name, for example, "childReport" given in the parentReport.jrxml's subReport location/expression as $P{SUBREPORT_DIR} + "childReport.jasper" Make sure that the child is compiled to a .jasper before running your parent. If you don't know how to do that let me know!!! Post edited by: pvradhakrishna, at: 2008/06/24 03:52
  10. I solved this by passing a hashmap parameter parameters.put("SUBREPORT_DIR", "actual path to the subreport.jasper file location" ); should also end with a '', don't forget escape characters '' if you are hard-coding the path rather than use a file.getAbosolutePath() or something.. You have to mention in the subReport.jasper location correctly. First check by opening in i-report the subReport.jrxml report properties to see if the name matches with the correct name, for example, "childReport" given in the parentReport.jrxml's subReport location/expression as $P{SUBREPORT_DIR} + "childReport.jasper" Make sure that the child is compiled to a .jasper before running your parent. If you don't know how to do that let me know!!!
  11. Thanks for the prompt reply. So had I created my object static fields getter and setter as Code:private Static Double avgMarketValue; //Getter and Setter public Double getAvgMarketValue() { return avgMarketValue; } public void setAvgMarketValue(Double avgMarketValue) { this.avgMarketValue = avgMarketValue; // with a warning though, // The static field objectClassName.avgMarketValue should be accessed in a static way } instead of Code:[code]private Static Double avgMarketValue; // Getter and Setter public static Double getAvgMarketValue() { return avgMarketValue; } public static void setAvgMarketValue(Double avgMarketValue) { WsoNqTaxDetail.avgMarketValue = avgMarketValue; } it should work for my class access as well as for jasper reports as jasper does not retrieve properties from static methods? Also, I was wondering where is the best way to start learning about using Hibernate (HQL) to create Jasper Reports, both passing external arrays/lists as data source as well as including the HQL query within the report itself. I have been looking for examples and templates to start with!
  12. Hi, I use Jasper Reports API to create custom PDF reports. Recently, I had to display a couple of fields which are rather constants (user inputs) and therefore defined as static in my .java object. I am able to access/print the static field values for all the list of objects by using the getter() methods. I get this list of objects directly from a Hibernate HQL query and I pass this list.toArray() as a data source to the report as follows. System.out.println(SomeList.get(0).getStaticField()); // This works fine jasperPrint = JasperFillManager.fillReport(jasperReport, hmapParam,new JRBeanArrayDataSource(SomeList.toArray())); // Results in an error However, the report breaks down saying "Error retrieving field value from bean." staticField...
  13. Subject: Using HQL field aliases as Jasper report fields. Hello, I am a newbie using Jasper and iReports to create my custom Java/Hibernate based reports. I recently came across an article which essentially shows how to avoid creating a list or array of objects (with field names) to be passed to a .jrxml file to create your report. Read: http://www.hibernate.org/79.html Title: Using JasperReports with Hibernate Problem: The article suggests using and passing the HQL result directly along with the equivalent field names passed as a separate String array or using alias. However, most of my queries involve using the HQL result sets again to iterate these columns/fields to calculate various other fields and then create other columns/fields out of these existing ones. How can I create or assign field names or pass equivalent string names to be used in the .jrxml file when I have calculated fields? One solution is to again create a brand new object with all the required fields and their field names matching with those used in the .jrxml file and hence I will be creating a list or array of these objects to be passed to the .jrxml file. Any suggestions will be appreciated. -Cheers Extra Information: Currently, I am using hibernate for reports and there we create various types of objects, meaning each object requiring anywhere from one, two, or all of the fields of the object. The hibernate HQL defines constructors of new objects in HQL as in the following example to return a list of objectAs' assuming you have defined a constructor with two fields and matching data types only in ObjectA's class: HQL: Code:query qry = "select new obj(obj1.field1, obj1.field2) from ObjectA obj1 where...."; return session.createQuery(qry).list() For other requirements I need other fields and I continue to create and add newer constructors in this class.
×
×
  • Create New...