2005 IR Help Posted August 26, 2006 Share Posted August 26, 2006 By: Todd - mrtodds How can I check if a file exists? 2004-05-17 11:44 I am trying to read in files, but some of them don't exist. I want to use a default graphic in this case. How can I check for the existence of the file before I try to display it? By: C-Box - c-box RE: How can I check if a file exists? 2004-05-17 12:48 You mean at RunTime or befor you load/compile/fill your report(s) ??? I guess you mean at runtime... then you should search for Scriptlet usage in that forum... I guess the "beforeDetail" method could work (depends in which band you've placed your image(s)) there you can change your missing image to your default image. hth C-Box By: Todd - mrtodds RE: How can I check if a file exists? 2004-05-17 18:12 Yes, at Runtime. I tried creating a scriptlet but I can't get them to compile. Not even the sample. They both keep giving me this error: C:iReport-0.2.2Form_36_Signature.java:189: cannot resolve symbol symbol : class SignatureExists location: package forms value = (java.lang.Boolean)(((com.ids.ccarweb.base.forms.SignatureExists)((dori.jasper.engine.JRAbstractScriptlet)parameter_REPORT_SCRIPTLET.getValue())).isValid()); Here is my scriptlet package com.ids.ccarweb.base.forms; import dori.jasper.engine.*; import java.io.File; /** * */ public abstract class SignatureExists extends JRAbstractScriptlet { /** * */ public Boolean isValid(String fileName) throws JRScriptletException { Boolean status = new Boolean(false); File myFileName = new File(fileName); status = new Boolean(myFileName.exists()); return status; } public String returnFilename(String fileName) throws JRScriptletException { boolean status = false; File myFileName = new File(fileName); String defaultSignature = "c:\Development\WEB_Development\CCARWEB\ccarweb\ccarweb\forms\images\bondurantd.jpg"; status = myFileName.exists(); if (status) { return fileName; } else {return defaultSignature;} } } How do I get these scriptlets to work? 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