feaganss Posted March 20, 2012 Share Posted March 20, 2012 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 More sharing options...
ranjitmishra Posted March 21, 2012 Share Posted March 21, 2012 the isFile() works for me.I did this:(new File("C:\\temp\\client_logo.jpg")).isFile()?"C:\\temp\\client_logo.jpg" : "E:\\temp\\default_logo.jpg" Link to comment Share on other sites More sharing options...
feaganss Posted March 21, 2012 Author Share Posted March 21, 2012 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 More sharing options...
lesegomot Posted May 10, 2012 Share Posted May 10, 2012 GreetingI 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 goodluckLsG Link to comment Share on other sites More sharing options...
ldalberti Posted November 7, 2012 Share Posted November 7, 2012 Hi, any update on a solution to this? I'm running into the same situation here. Thanks! Link to comment Share on other sites More sharing options...
mgolisch_1 Posted January 10, 2013 Share Posted January 10, 2013 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 More sharing options...
djsadbg Posted March 7, 2013 Share Posted March 7, 2013 Hard image question...you can google or wikipedia... Link to comment Share on other sites More sharing options...
kowalik.michal Posted September 27, 2013 Share Posted September 27, 2013 ranjitzulu, many thanks for tips, excelent works with dynamic links(new File($P{ROOT_DIR} + $P{IMAGE_DIR} + $F{CLIENT_ID} + ".jpg")).isFile()? $P{ROOT_DIR} + $P{IMAGE_DIR} + $F{CLIENT_ID} + ".jpg" : $P{ROOT_DIR} + $P{IMAGE_DIR} + "Default_company.jpg" 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