Jump to content
JasperReports Library 7.0 is now available ×

Use different field names in JavaBean and Report


Max3614

Recommended Posts

I am working on an international project where we're facing what might be called a translation issue. It's been plaguing us for a while, so any help would be greatly appreciated!

We're developing a Java project and using JRBeanCollectionDataSources to create PDF reports.

The issue is that the Java developers speak only English, while the people creating the report templates speak only German. We thus want our Java code to be written completely in English, while our report parameters and field names should be German. So the question is: is there a way of having different field names for the Java Bean and the report?

I am aware that one can solve similar issues by setting isUseFieldDescription = true. In our case, we could have report fields with German names and English descriptions. Then we would use these descriptions as names for the fields of our JavaBean. 

But this workaround has three considerable drawbacks:

  1. There is no single point of truth for the translation between English and German field names. If we wanted to rename the fields of our JavaBean, we'd have to adjust the field definitions in dozens, maybe hundreds, of report templates.
  2. We can't use the field description to actually describe the field to the people creating and maintaining the report templates.
  3. It might not be clear to the template creators that the English field descriptions cannot be changed (e.g. replaced with German ones) without breaking the PDF generation.

Surely there must be a better solution avoiding these pitfalls. Yet, we have not managed to find one thus far, so it would be really amazing if someone here could suggest something!

P.S. We've found a reasonably straightforward way of addressing the same issue for report parameters. Here, we simply created an enum that assigns German parameter names to English constants. The translation thus happens at a single place in the project - nice and clean! Now we'd like to do the same thing for fields...

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...