[#7481] - Field names mapped to bean names automagically

Category:
Feature request
Priority:
Low
Status:
New
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

Currently, the following code is written to map Beans to Fields:

<field name="student.address.streetLine1" class="java.lang.String">
<fieldDescription><![CDATA[student.address.streetLine1]]></fieldDescription>
</field>
<field name="student.address.streetLine2" class="java.lang.String">
<fieldDescription><![CDATA[student.address.streetLine2]]></fieldDescription>
</field>
<field name="student.address.city" class="java.lang.String">
<fieldDescription><![CDATA[student.address.city]]></fieldDescription>
</field>
<field name="student.address.province" class="java.lang.String">
<fieldDescription><![CDATA[student.address.province]]></fieldDescription>
</field>
<field name="student.address.postalCode" class="java.lang.String">
<fieldDescription><![CDATA[student.address.postalCode]]></fieldDescription>
</field>

Since the name and the data type is exposed via reflection, the data type ("class='java.lang.String'") can be inferred. As such it is likely that the entire mapping can be simplified as follows:

<fieldSet adapterName="StudentAdapter" /> or <fieldSet factoryMethod="JRDataSourceFactory.createStudent" /> or similar

This would then automatically introspect the collection's genericized class (via the data adapter; e.g., Collection<**Student**> createStudent()) and expose the fields using dot notation (that exactly corresponds to the bean's accessor method call chain found in the fieldDescription).

Certainly this won't work for all cases, but it shoulder certainly work for POJOs.

AttachmentSize
Image icon student.png14.54 KB
v6.2.2
Data Adapters
thangalin's picture
1451
Joined: Apr 21 2008 - 4:34am
Last seen: 2 years 6 months ago

1 Comment:

#1
  • Assigned:nobody» teodord
Feedback
randomness