2002 JI Open Discussion Posted August 19, 2006 Share Posted August 19, 2006 By: Olivier - opoppon Examples with Bean collection and reflection 2003-11-21 08:12 Hi, I have just discovered jasper and iReport. I've gone through different sites, forums...but it seems that there aren't much examples of using jasper with bean collection. Basically I have trouble creating parameter/fields of anything else but the default type (ex: Employee), and then access the properties of this bean using reflection. Something like $P{employee}.getName() Has anyone come across such examples ? Thanks, Olivier By: Gregory A. Swarthout - gswarthout RE: Examples with Bean collection and reflect 2003-11-21 11:15 If you are using an object of a custom bean class, you will have to pass it in as a java.lang.Object and then cast it to its correct type when you use it. ie: ((Employee)$P{employee}).getName() By: Olivier - opoppon RE: Examples with Bean collection and reflection 2003-11-24 00:08 Thanks. worked fine. By: Olivier - opoppon RE: Examples with Bean collection and reflection 2003-11-24 02:25 I managed to display the value of the field for this object that I passed as a parameter. Now, I would like to do the same, for a collection of Employee. This is how I try to do things : in the java file: list = new Vector(); list.add( new Employee("Doe1", new Integer(1))); list.add( new Employee("Doe2", new Integer(2))); JasperManager.fillReport( jasperReport, parameters, new JRBeanCollectionDataSource( list)); in the xml file : (trying to guess how it should be here) <field name="employee" class="java.lang.Object"/> <variable name="name" class="java.lang.String" ....> <variable expression>((Employee)$F{employee}).getNom()</></> <group name="employeeList" ...> <groupExpression>null</groupExpression> </group> .... <detail> ... <textFieldExpression class="java.lang.String">$V{name}</textFieldExpression> </detail> I would like to know if my understanding is more or less correct. Thanks, Olivier By: Gregory A. Swarthout - gswarthout RE: Examples with Bean collection and reflect 2003-11-24 11:35 >I would like to know if my understanding is more or less correct. Less, I'm afraid. In this case I'm going to admonish you to RTFM. 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