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

Cannot found Image!!! need help..URGENT


2005 IR Help

Recommended Posts

By: kjwong - kjwong

Cannot found Image!!! need help..URGENT

2005-12-06 18:15

Hi,

I using iReport 0.3.0 to develop a report.

I pass the PARAMETER to Ireport and get the image to disply out.But, the PARAMETER e.g $P{imageBarcode},it is automatic get the image file name in my Java coding.

My question is....

how can the report display without error when it cannot find any image file?

 

I means, the report whether is no image found or have image oso can be display out. How can I do it????

 

 

 

 

By: cfi - delphinecfi

RE: Cannot found Image!!! need help..URGENT

2005-12-07 06:17

In the java code itself check for conditions when there is no image. No add a new variable called SHOW_IMAGE in the report design also add another field SHOW_IMAGE. IN the java code when there is no image set SHOW_IMAGE = 0, otherwise, set it to 1. In the report design, for the image element say print when expression as (Integer.parseInt($V{SHOW_IMAGE}.toString()) == 1)?Boolean.TRUE:Boolean.FALSE. This condition would take care of showing the image only when it is present.

 

When adding the variable name in the report design, set Expression to $F{SHOW_IMAGE} and set initial value expression as 0.

 

The type of variable SHOW_IMAGE and the fiels SHOW_IMAGE should be the same. For the type of expression i have used here, use java.lang.String.

 

Hope this helps!

 

 

 

 

By: kjwong - kjwong

RE: Cannot found Image!!! need help..URGENT

2005-12-08 20:35

First of all, thank for you immediate feedback.

 

Anyway, the given solution still cannot solve the problem that i have it now. I'm not able to know whether there is an image file in my java code itself. The image file is dynamically generated, eg, $P{barcode}+ $F{officialreceiptdocumentnumber} +".jpg". In certain situation, the system might have official receipt document number, but does not have image file (officialreceiptdocumentnumber.jpg).

 

I just cannot find a way to solve this issue. Hopefully, u can help me on this.

 

Thanks

 

 

 

 

By: cfi - delphinecfi

RE: Cannot found Image!!! need help..URGENT

2005-12-09 06:42

In the javacode, since you know 'barcode' and 'officialreceiptdocumentnumber' try doing as shown below. Save the generated image to some directory like C:/APPS/MYAPPS/DATA/<FILENAME>

 

String strFileName = strbarcode + strofficialreceiptdocumentnumber+".jpg";

 

String strDir= "C:/APPS/MYAPPS/DATA/";

File fImageLoc = new File(strDir);

 

if(!fImageLoc.isDirectory())

fImageLoc.mkdirs();

 

String strImage = strDir + strFileName;

File fImageFile = new File(strImage);

 

if (!fImageFile.exists())

{

// here set SHOW_IMAGE to "0"

}

else

{

// here set SHOW_IMAGE to "1"

}

 

Hope this helps.

 

-Delphine.V

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

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