Jump to content
We've recently updated our Privacy Statement, available here ×

Checking for existence of Image in the Repository


feaganss

Recommended Posts

 Hi,

I'm using iReport 4.1.1 and have a report that pulls the customer's logo dynamically from the Images folder in the repository based on a Parameter value.  It's very simple, and works just fine:  "repo:/Images/" + $P{CustomerID} + ".jpg".  

However, some customers don't have logos yet, and for those I want to display a default logo "repo:/Images/CCMCLogo" (this also loads successfully if I set the image source to it).  

What I'd like to do is check for the existence of "repo:/Images/" + $P{CustomerID} + ".jpg" in the Repository;  if it exists then use it, else use "repo:/Images/CCMCLogo".  However, I'm not sure what syntax to use to check for the existence of a resource - checking for it as a file always returns false.  

Here's the syntax I've tried:  (new File("repo:/Images/" + $P{CustomerID} + ".jpg")).exists() ? "repo:/Images/" + $P{CustomerID} +".jpg" :  "repo:/Images/CCMCLogo", and I've also tried it with isFile() instead of exists(), but it always returns false.

Does anyone know how I can check for the existence of an image in the repository?

Thank you!

Shawn

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

 Thank you for the reply.  I'm also able to check for the existence of a file in the file system, but what I'm having trouble with is checking for the existence of a resource in the repository - e.g. repo:/Images/CCMCLogo

Link to comment
Share on other sites

  • 1 month later...

Greeting

I have been banging my head on the wall for hours now, did you finally find a solution to this?

I'll keep trying on my side and will inform you if/when i do.

I reports has the "On error type" option, but it seems not to work on jasper4.5.1 when the image does not exists it throws an error irrespective of your choice on the attribute.

So i'm trying to work with the "print when expression" attribute

 

Cheers and goodluck

LsG

Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...

bump....

 

Anyone?

Running into the exact same Problem.All worked well when we build the reports using jasperreports library and local filesystem resources, but it doesnt work no more in jasperservers repository.The On Error Type Blank setting doesnt work either. It just presents an ugly exception message to the user instead of just outputing the report without the image.

So how do i check if it exists in my report?

Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...

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...