Jump to content
Changes to the Jaspersoft community edition download ×

icccapital

Members
  • Posts

    12
  • Joined

  • Last visited

icccapital'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. UPDATE--I apologize. I believe I found my mistake, having nothing to do with the jasperfillmanager or the jasperprint object. Pleae feel free to delete this post. I couldn't find the delete to do it myself. Sorry again. Post Edited by supjohn at 08/09/2012 20:25
  2. I am trying to test a report that uses java beans for its data source. The createBeanCollection method uses MyBatis to fill the java beans and returns a list of the beans. The application runs fine filling the beans and returning the list of beans from createBeanCollection when I test it. But when I try to preview the report in IReport i get the error below. When I compile the report I can run it in the application and everything works fine. I am trying to edit the look of the report with live data, but can't easily because of this issue. the org/apache/ibatis/io/Resources class is in the mybatis jar, which is in the dist/lib of the project. java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.jaspersoft.ireport.designer.connection.JavaBeanDataSourceConnection.getJRDataSource(JavaBeanDataSourceConnection.java:163) at com.jaspersoft.ireport.designer.IReportConnection.getJRDataSource(IReportConnection.java:71) at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:914) at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572) at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: java.lang.NoClassDefFoundError: org/apache/ibatis/io/Resources at org.myapp.controller.MyBatisHelper.getSession(MyBatisHelper.java:27) at testbean.TestBean.createBeanCollection(TestBean.java:37) ... 9 more
  3. I have put several text fields in the page header band and shrunk them down to near 0 height. I then put them to stretch on overflow. The reason for this is to create an address, phone, fax...etc without having a lot of whitespace if an address is not provided or the phone number is not provided. so the text fields have conditional line breaks( "\n"). All works well, but now when they expand they are increasing the size of the page header. There are no controls below these controls, but there are controls to the right. The ones on the right do not move, but the whitespace below the text field controls do. I know this because I put a box around the last text field control and it is well above the bottom of the page header band. Is there anything that can be done about this? Code:<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="ClientReportsSummary" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="fc68a490-ccb6-4504-a00b-0f19b73a0668"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA["C:\\Users\\upjohs.xp\\My Documents\\NetbeansProjects\\JSFTest_2_1\\src\\java\\jasperreports\\"]]></defaultValueExpression> </parameter> <queryString> <![CDATA[]]> </queryString> <field name="contactAddress" class="java.lang.String"> <fieldDescription><![CDATA[contactAddress]]></fieldDescription> </field> <field name="contactAddress2" class="java.lang.String"> <fieldDescription><![CDATA[contactAddress2]]></fieldDescription> </field> <field name="contactCity" class="java.lang.String"> <fieldDescription><![CDATA[contactCity]]></fieldDescription> </field> <field name="class" class="java.lang.Class"> <fieldDescription><![CDATA[class]]></fieldDescription> </field> <field name="contactCompanyName" class="java.lang.String"> <fieldDescription><![CDATA[contactCompanyName]]></fieldDescription> </field> <field name="contactEmailAddress" class="java.lang.String"> <fieldDescription><![CDATA[contactEmailAddress]]></fieldDescription> </field> <field name="contactFax" class="java.lang.String"> <fieldDescription><![CDATA[contactFax]]></fieldDescription> </field> <field name="contactFirstName" class="java.lang.String"> <fieldDescription><![CDATA[contactFirstName]]></fieldDescription> </field> <field name="contactLastName" class="java.lang.String"> <fieldDescription><![CDATA[contactLastName]]></fieldDescription> </field> <field name="contactPhoneNumber" class="java.lang.String"> <fieldDescription><![CDATA[contactPhoneNumber]]></fieldDescription> </field> <field name="contactState" class="java.lang.String"> <fieldDescription><![CDATA[contactState]]></fieldDescription> </field> <field name="contactZipCode" class="java.lang.String"> <fieldDescription><![CDATA[contactZipCode]]></fieldDescription> </field> <field name="clientAddress" class="java.lang.String"> <fieldDescription><![CDATA[clientAddress]]></fieldDescription> </field> <field name="clientAddress2" class="java.lang.String"> <fieldDescription><![CDATA[clientAddress2]]></fieldDescription> </field> <field name="clientCity" class="java.lang.String"> <fieldDescription><![CDATA[clientCity]]></fieldDescription> </field> <field name="clientCode" class="java.lang.String"> <fieldDescription><![CDATA[clientCode]]></fieldDescription> </field> <field name="clientName" class="java.lang.String"> <fieldDescription><![CDATA[clientName]]></fieldDescription> </field> <field name="clientNumBooks" class="java.lang.Integer"> <fieldDescription><![CDATA[clientNumBooks]]></fieldDescription> </field> <field name="clientServicePerson" class="java.lang.String"> <fieldDescription><![CDATA[clientServicePerson]]></fieldDescription> </field> <field name="clientState" class="java.lang.String"> <fieldDescription><![CDATA[clientState]]></fieldDescription> </field> <field name="clientZipCode" class="java.lang.String"> <fieldDescription><![CDATA[clientZipCode]]></fieldDescription> </field> <field name="specialNotes" class="java.lang.String"> <fieldDescription><![CDATA[specialNotes]]></fieldDescription> </field> <field name="clientList" class="java.util.List"> <fieldDescription><![CDATA[clientList]]></fieldDescription> </field> <pageHeader> <band height="101" splitType="Prevent"> <staticText> <reportElement uuid="9cb6b6bd-b670-4ea0-a98e-ce0ca6422cd7" x="0" y="0" width="49" height="14" forecolor="#3399FF"/> <textElement/> <text><![CDATA[Contact:]]></text> </staticText> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement uuid="35aed98f-5430-4913-9e10-1f1a92c957f1" x="0" y="14" width="100" height="0"> <printWhenExpression><![CDATA[$F{contactCompanyName} != null && $F{contactCompanyName}.compareTo("") != 0]]></printWhenExpression> </reportElement> <textElement/> <textFieldExpression><![CDATA[$F{contactCompanyName}]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement uuid="bb5a6f92-2f5d-45ad-9fca-78c906676e4b" positionType="Float" x="0" y="16" width="100" height="0"/> <textElement/> <textFieldExpression><![CDATA[$F{contactAddress} + ($F{contactAddress2} != null && $F{contactAddress2}.compareTo("") != 0 ? "\n" + $F{contactAddress2} : "")]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement uuid="c40ed505-58a0-48f9-a629-bf15d8384c9f" positionType="Float" x="0" y="18" width="100" height="0"/> <textElement/> <textFieldExpression><![CDATA[($F{contactCity}==null ? "" : $F{contactCity}) + ", " + ($F{contactState}==null ? "" : $F{contactState}) + " " + ($F{contactZipCode}==null ? "" : $F{contactZipCode})]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement uuid="3be90961-7d34-443c-ac97-53f2f45da889" positionType="Float" x="0" y="19" width="100" height="0"/> <box> <topPen lineWidth="0.5" lineStyle="Solid"/> <leftPen lineWidth="0.5" lineStyle="Solid"/> <bottomPen lineWidth="0.5" lineStyle="Solid"/> <rightPen lineWidth="0.5" lineStyle="Solid"/> </box> <textElement/> <textFieldExpression><![CDATA[$F{contactPhoneNumber} + ($F{contactFax} != null && $F{contactFax}.compareTo("") != 0 ? "\n" + $F{contactFax} : "") + ($F{contactEmailAddress} != null && $F{contactEmailAddress}.compareTo("") != 0 ? "\n" + $F{contactEmailAddress} : "")]]></textFieldExpression> </textField> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement uuid="3ee3a448-32dd-47d4-a32e-c82ad9d7c562" positionType="Float" x="0" y="15" width="100" height="0"/> <textElement/> <textFieldExpression><![CDATA[$F{contactFirstName} + " " + $F{contactLastName}]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement uuid="01991e9a-95b6-4653-b326-3c31f03d7044" x="199" y="16" width="180" height="15"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[($F{clientCode} == null ? "" : $F{clientCode})]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement uuid="be71e01f-d410-4234-ae39-5874f7b8ec78" x="199" y="31" width="180" height="15"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$F{clientAddress} + ($F{clientAddress2} != null && $F{clientAddress2}.compareTo("") != 0 ? "\n" + $F{clientAddress2} : "")]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement uuid="44285da9-723b-480f-8bbc-33f2b2d9cfac" x="199" y="46" width="180" height="15"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[($F{clientCity}==null ? "" : $F{clientCity}) + ", " + ($F{clientState}==null ? "" : $F{clientState}) + " " + ($F{clientZipCode}==null ? "" : $F{clientZipCode})]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement uuid="630790c2-d522-4e67-9393-00a39ab7e69b" x="199" y="2" width="180" height="15"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$F{clientName} == null ? "" : $F{clientName}]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement uuid="2a2e4fb7-467b-47f2-97f0-20b26a9e1908" x="199" y="61" width="180" height="15"/> <textElement textAlignment="Center"/> <textFieldExpression><![CDATA[$F{clientServicePerson} == null ? "" : $F{clientServicePerson}]]></textFieldExpression> </textField> <textField isBlankWhenNull="true"> <reportElement uuid="7e95cf5c-c027-4f17-bc73-e445b50013d2" x="302" y="76" width="20" height="15"/> <textElement/> <textFieldExpression><![CDATA[$F{clientNumBooks}]]></textFieldExpression> </textField> <staticText> <reportElement uuid="0171e5a2-928e-47fd-982d-76126f0bbc0a" x="258" y="76" width="44" height="15" forecolor="#3399FF"/> <textElement/> <text><![CDATA[#Books:]]></text> </staticText> <line> <reportElement uuid="871dcc80-7952-46ce-adb1-b986d6d1cf29" positionType="Float" x="236" y="91" width="92" height="1"/> </line> </band> </pageHeader> <detail> <band height="365" splitType="Prevent"> <subreport> <reportElement uuid="4a6572e5-4628-445f-a8e2-234e96737522" isPrintRepeatedValues="false" x="88" y="0" width="413" height="0"/> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{clientList})]]></dataSourceExpression> <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "ClientReportsSummary_subreport1.jasper"]]></subreportExpression> </subreport> <staticText> <reportElement uuid="5f9e3e69-12f4-4abf-9294-6325873973f3" positionType="Float" x="111" y="14" width="100" height="15" forecolor="#3399FF"/> <textElement/> <text><![CDATA[special Notes:]]></text> </staticText> <textField isStretchWithOverflow="true" isBlankWhenNull="true"> <reportElement uuid="94a84333-c8ae-4ca1-a532-19198fb3f2b1" positionType="Float" x="111" y="29" width="355" height="119"/> <box> <topPen lineWidth="0.5" lineStyle="Solid"/> <leftPen lineWidth="0.5" lineStyle="Solid"/> <bottomPen lineWidth="0.5" lineStyle="Solid"/> <rightPen lineWidth="0.5" lineStyle="Solid"/> </box> <textElement/> <textFieldExpression><![CDATA[$F{specialNotes}]]></textFieldExpression> </textField> </band> </detail></jasperReport>
  4. I stepped away from the project for a bit and so just came back and figured out what I was doing wrong. For those who need this info, I figured out that you have to have the createBeanCollection (aggregator of the list of objects) method in the bean that has all of the attributes. Maybe in future versions this won't be a limitation.
  5. I am at a total loss. I have gotten this to work before, but everything I have done I can't seem to get the attributes to display in the report query in Ireport. My code is below for the factory class. I have jarred the three classes in one jar file. I have added the jar file to the classpath in ireport and I have created a new connection/datasource with the following information JavaBeans set datasource name: Mailers FactoryClass: beanCollect.BeanCollection checked Collection of JavaBeans method: createBeanCollection Can anyone give me something else to try, thanks Code:/* * To change this template, choose Tools | Templates * and open the template in the editor. */package beanCollect;import java.util.ArrayList;import java.util.List;import org.myapp.model.Contacts;import org.myapp.model.Clients;public class BeanCollection { public static List createBeanCollection(){ List<Clients> myList = new ArrayList<Clients>(); Contacts co = new Contacts(); Clients cl = new Clients(); co.setiD1(new Long(10)); co.setCompany("Company"); co.setFirstName("Bill"); co.setLastName("Lung"); co.setAddress("10 place"); co.setAddress2("Address 2"); co.setCity("Orlando"); co.setState("FL"); co.setZipCode("32801"); List<Contacts> lc = new ArrayList<Contacts>(); cl.setPosition("Doctor"); lc.add(co); cl.setContacts(lc); myList.add(cl); return myList; }}
  6. I have two tables Clients and Contacts. Each client can have multiple contacts and each Contact can be attached to multiple Clients. I have modeled this with two classes Clients and Contacts. I want to create a report that will pull the contact information (name, address, company) from the contacts class and their position (which resides in the clients table/class). This data will produce a cover sheet for mailers ( ie First Name Last Name Address Position..... I understand the need for subreports when dealing with multiple classes when there is a 1-to-many situation, but what is the best way to model the scenario above? I was thinking one possibility to create a new class (MailerTopSheet) and have just the fields needed, but that seemed kind of rigged. Is this the way people normally handle it or is there a better way? Thanks.
  7. Thank you for the reply. I was hoping to avoid using a subreport, but after doing some reading and getting your reply that seems to be the only way to handle it.
  8. How would I populate a jasper report for a one-to-many relationship? Below is a silly example, but it makes the point for the question. Instead of having 4 Car objects I have just one and the 4 tires are a list of the Car. 1) Can Jasper report handle this? 2) if no, then would I need to collect a list of Car objects and TireType objects, keeping them together? ie {Car1, Tire1}, {Car1, Tire2}....{Car2, Tire1} etc. 3) Or do is it required to use sub-reports in this situation (I can create the report without subreports using sql code as the base of the report so I was hoping to have it work the same way with beans. Thank you. Code: Post Edited by icccapital at 01/27/2011 15:33
  9. Thanks for the reply. I think I have figured out the issue, but please tell me if I am wrong. I have two java beans one bean contains a list of the other bean to try to mirror a one to many relationship of the data. I was trying to pass this bean in the collection to jasper. It seems that Jasper won't look for fields within the list of the second bean, is that correct? I have been reading to try to find a solution to my problem other than just writing the query in the report. If anyone knows how to solve for this either by creating a collection that contains both beans or anything it would be helpful. Thanks to all for the thoughts. example code is below Code:public class Client{ private List<Addresses> a; public getA();....}public class Addresses{ get/set....}
  10. My setup is that I have a bean that I want to fill my report with. The code below is how I try to run my report where cc is an instance of the ClientCode bean. I am getting an error "Error retrieving field value from bean: ClientCode". Is there a way to get more information than this or is there something obvious that I am doing wrong. Please let me know if there is more information needed. Thanks in advance for the help. Code:List<ClientCode> dl = new ArrayList<ClientCode>(); dl.add(cc); JasperPrint jp = JasperFillManager.fillReport("c:\\documents and settings\\upjohs.ICCCAP\\My Documents\\NetbeansProjects\\MyBatis\\src\\report1.jasper", m, new JRBeanCollectionDataSource(dl)); JasperViewer.viewReport(jp);
  11. teodord, Thanks for the reply, I know my question was very open ended, but your thoughts were helpful in clarifying my thinking. I guess what I was trying to figure out is if there is a significant overhead difference between using mybatis and object versus allowing jasper to access the database itself with jdbc. But based on your answer it would seem there isn't just more of a question of how many successive uses of the data and size of the data requested if I am thinking correctly. Thanks again.
  12. I am creating a web application using JSF and MyBatis. It seems reasonable to want to keep all sql and connections in the MyBatis portion, but when doing some research I am not sure if that is the best thing for Jasper Reports. Does anyone have an opinion on this? Is it bad to pass a collection of javabean objects to Jasper as a datasource? Is it prefered to have Jasper access through JDBC directly the data? Thanks
×
×
  • Create New...