-
FEATURED COMPONENTS
First time here? Check out the FAQ!
***SOLVED***
Hi all,
I'm totally new with JasperReports,
I'm searching how to declare a field for a bean attribute of a bean ?
Example :
If I have a bean Person and this bean have a bean attribute car.
public class Person { private Car car; ... } Private class Car { private String dealer; ... }
<field name="car.dealer" class="java.lang.String"> <fieldDescription><![CDATA]></fieldDescription> </field>
$F{car.dealer}
Have a look at following code:
kunde.java (Bean)
public class Kunde implements java.io.Serializable { private static final long serialVersionUID = -7921214349365225047L; private long kunId = Long.MIN_VALUE; private int version; private Filiale filiale; private Branche branche; private String kunNr = ""; private String kunMatchcode = ""; private String kunName1 = ""; private String kunName2 = ""; private String kunOrt = ""; private Boolean kunMahnsperre = false; private Set<Auftrag> auftrags = new HashSet<Auftrag>(0); ... getter/setter
testreport.jrxml
... <field name="kunName1" class="java.lang.String"> <fieldDescription><![CDATA]></fieldDescription> </field> <field name="kunName2" class="java.lang.String"> <fieldDescription><![CDATA]></fieldDescription> </field> ... here is a property that references to another Bean <field name="branche" class="de.daibutsu.backend.model.Branche"> <fieldDescription><![CDATA]></fieldDescription> </field> here is a property that references to another Bean <field name="filiale" class="de.daibutsu.backend.model.Filiale"> <fieldDescription><![CDATA]></fieldDescription> </field> ...
regards
Stephan
Thanks Stephan I will do like in your example.
And for accessing ? Something like that ?
$F{filiale.getSomeProperty()}
Use the iReport for creating the report.
Use the native version.
The NetBeansPlugin have problems to create the xml file correctly.
I have accessed per JRBeanDataSource because i'm going against a hiberntae backend.
There are several datasource templates in the iReport.
Stephan
Thanks Stephan,
The data source of my report is a JRBeanCollectionDataSource.
Yes i'm using iReport, but I had many problems to use hibernate connection in it.
So i'm using a JDBC connection to make the report, then I delete the queryString tag and I change the field declaration name to be like the bean.
But right now i can't make work even with a small report. I mean it's working in iReport before the change, but not in Zk after the change.
I get this error each time when I try to my rapport .jasper with ZK.
... Caused by: java.lang.NoSuchMethodException: Unknown property '' on class 'class bonDeTravails.BonDeTravailDTO' at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1313) ...
SOLVED :
On the forum of Jasper they tell me to :
You should either Remove the empty field descriptions from the JRXML. Pass false as isUseFieldDescription when creating the bean data source, e.g. new JRBeanCollectionDataSource(data, false).
Asked: 2009-04-06 13:50:30 +0800
Seen: 496 times
Last updated: Apr 07 '09