bengateau Posted January 6, 2009 Share Posted January 6, 2009 Hi all, Using JR 3.1.2, iReport for JR 3.1.2, and Maven plugin for compiling. I have image stored in Java in a byte array and would like to display it in a report. I read here that JR would accept any Java object as a parameter, but I cannot figure how to do it. When defining new parameter (using iReport) only some class types are available, so I chose Object. When I tried to add this filed to "Last Page Footer", program was changing the type to String. I can change it manually, but then I'm getting:Error compiling report design :c:reportssrcmainjasperreportsuser.jrxml :org.xml.sax.SAXParseException: cvc-enumeration-valid: Value 'java.lang.Object' is not facet-valid with respect to enumeration '[java.lang.Boolean, java.lang.Byte, java.util.Date, java.sql.Timestamp, java.sql.Time, java.lang.Double, java.lang.Float, java.lang.Integer, java.lang.Long, java.lang.Short, java.math.BigDecima l, java.lang.Number, java.lang.String]'. It must be a value from the enumeration. Any suggestions how to accomplish this? I was trying to use Byte instead of the Object, but then I was getting CastingException. Thank you for reading. Cheers, Ben Link to comment Share on other sites More sharing options...
bengateau Posted January 8, 2009 Author Share Posted January 8, 2009 My question should really be how to use parameters with type different from the 13 types listed in the error above? I'd be grateful if someone could tell me how to do that. Thanks, Ben. Link to comment Share on other sites More sharing options...
lucianc Posted January 9, 2009 Share Posted January 9, 2009 I don't understand what the problem is.JasperReports allows you to define parameters of any type. The 13 types you listed are valid types for text field expressions. Are you trying to display the byte array in a text field? If so, you will need to explicitly convert it to a String object.Regards,Lucian Link to comment Share on other sites More sharing options...
bengateau Posted January 9, 2009 Author Share Posted January 9, 2009 Hi Lucian, Yes you are right, I was defining byte array parameter as an object and when I was adding it to the page it was by default added as a String in text field. The byte array was image which I wanted to display on the report, so first I had to convert byte array to ByteArrayInputStream on the Java side, define parameter as type InputStream, and then display it within the image, also as InputStream type. All is good now :) Thank you for your assistance.Regards, Ben 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