One field with different types?

0

Hello, 

i have field

 <field name="value" class="java.lang.String"/>

It may contains four kinds of data: Date, Boolean, Number, String
 
How to display it? There is always problem with cast. How tell Jasper to recognize proper type depends of value data?
insearchofsunrise's picture
Joined: Nov 17 2014 - 8:01am
Last seen: 5 years 5 months ago

3 Answers:

0

Hi there - Have you considered using the Java methods that are available from the Expression Editor?  Those methods are powerful and will help you manage your data fields.  Let me know.

H Mendoza's picture
351
Joined: Feb 20 2013 - 11:39am
Last seen: 1 year 1 month ago
0

You've defined your field to be of type String so the value will be stored as a String.

hozawa's picture
63700
Joined: Apr 24 2010 - 4:31pm
Last seen: 1 year 1 month ago
0

I've got another method by controling in java code:

define this field as String

override the getFieldValue(JRField paramJRField) in your relative dataSource class

when you get the value in your java code ,you can convert them to a string.

65644341's picture
Joined: Nov 20 2014 - 12:28am
Last seen: 5 years 6 months ago
Feedback
randomness