• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

byte array as a parameter in JasperReports

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 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 use parameters with type different from the 13 types listed above? I was trying to use Byte instead of the Object, but then I was getting CastingException.

Thank you for reading. Cheers, Ben
 
Ben Gateau Jr
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found the solution to my problem, I'll put the solution here if someone has the same problem.
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.
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ben,

Thanks for posting your findings, it'll definitely help some people out there in the future!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic