Re: EO accessors and Jasper Reports
Re: EO accessors and Jasper Reports
- Subject: Re: EO accessors and Jasper Reports
- From: Theodore Petrosky <email@hidden>
- Date: Wed, 13 Jul 2016 16:57:46 -0400
Thanks, this is working beautifully. I will write it up and put in on the wiki. (I tend to do that so I can find it later when I need to repeat it and can not remember the project I used it on.
I am finding that although I really like Jasper Reports, there are some idiosyncrasies in the newest version (6.3.0) that makes it not wonderful.
Thanks again.
Ted
> On Jul 13, 2016, at 8:01 AM, Hugi Thordarson <email@hidden> wrote:
>
> If JasperReports is using the correct/specification way to find accessor methods (and that’s a big if—many frameworks just assume getters are prefixed with “get”) you can provide a BeanInfo class to specify the names of accessor methods. A BeanInfo class should be located in the same folder/package as the class it describes and be called [YourClassName]BeanInfo.java.
>
> https://docs.oracle.com/javase/8/docs/api/java/beans/BeanInfo.html
>
> Here’s an example BeanInfo class for one of my entities. It returns a list that contains a PropertyDescriptor for each of the methods you want to describe. The arguments to the PropertyDescriptor constructor are the name of the property, the class containing the property, name of the getter method and name of the setter method.
>
> ——————————————————————————
>
> package is.ismus.model.auto;
>
> import java.beans.IntrospectionException;
> import java.beans.PropertyDescriptor;
> import java.beans.SimpleBeanInfo;
> import java.util.ArrayList;
> import java.util.List;
>
> public class _ModeBeanInfo extends SimpleBeanInfo {
>
> @Override
> public PropertyDescriptor[] getPropertyDescriptors() {
> try {
> List<PropertyDescriptor> list = new ArrayList<>();
>
> list.add( new PropertyDescriptor( "creationDate", _Mode.class, "creationDate", "setCreationDate" ) );
> list.add( new PropertyDescriptor( "englishName", _Mode.class, "englishName", "setEnglishName" ) );
>
> PropertyDescriptor[] array = new PropertyDescriptor[list.size()];
> array = list.toArray( array );
> return array;
> }
> catch( IntrospectionException e ) {
> throw new RuntimeException( e );
> }
> }
> }
>
> ——————————————————————————
>
> Cheers,
> - hugi
>
>
>
>> On 13. júl. 2016, at 11:46, Theodore Petrosky <email@hidden> wrote:
>>
>> I have been using Jasper Reports for a few years in my D2W apps. I am starting a new app and accessors for Jasper has always bothered me.
>>
>> My EO has some text attributes. (firstName, lastName for example) Jasper Reports seems to require accessors in the form of get<name>. In the past I just bit the bullet and added cover accessors:
>>
>> public String getFirstName() {
>> return this.firstName();
>> }
>>
>> public String getLastName() {
>> return this.lastName();
>> }
>>
>> Without these accessors, Jasper will not see my attributes.
>>
>> Is there a property for this? Am I working too hard? I am going over Kieran’s Jasper Reports videos and I don’t see that he had to add the accessors, so there must be someplace to set this.
>>
>> Ted
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden