rfcmahesh Posted March 2, 2009 Share Posted March 2, 2009 Hello, I am using JRBeanCollectionDataSource as my data source. One of the fields in the bean is an enum type. When I use that property as a field in the report, I get class cast saying Enum cannot be converted to String. I even tried doing $F{enumProperty}.toString(), but it still complains. Can someone please give some pointers.Thanks, Link to comment Share on other sites More sharing options...
rfcmahesh Posted March 4, 2009 Author Share Posted March 4, 2009 Figured a way to solve the issue.Make the field which corresponds to enumType as Object and the textField expression as String. It works for me.Code:effectiveType is an enum type in my bean.<field name="effectiveType" class="java.lang.Object"/>The text field expression is<textFieldExpression class="java.lang.String"><![CDATA[""+$F{effectiveType}]]></textFieldExpression> 1 Link to comment Share on other sites More sharing options...
ivo.mrqs Posted January 27, 2020 Share Posted January 27, 2020 public enum EnumTest { TestValue1(1, "Value for displayed 1"), TestValue2(2, "Value for displayed 2"), private Integer id; private String description; public String getDescription() { return description; }}you can call method your enum for example : $F{fieldForEnumTest}.getDescription(); 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