setting image path from database

Hi all:
What I need to do is like a catalog. There's gonna be Items and the item's element are field of a database. In Example: Item's picture is a path to the picture stored as a string in the database.
Should I just put that field name into the image expression field? or I have to do a more complex walkaround.

thanks anyway.
Matias


pd: this new forum looks great, congratulations
el_itur's picture
91
Joined: Jul 18 2006 - 5:10am
Last seen: 16 years 10 months ago

4 Answers:

Yes, you have simply to set as image expression something like:

$F{YourImagePathField}

Giulio
giulio's picture
71765
Joined: Jan 2 2007 - 4:15pm
Last seen: 3 weeks 2 days ago
thanks for the fast feedback.

Well the question was becouse ireport is giving me a error while testing with blank datasource. It tells me that there's no image.
I realize that it happens even with the images I set in design time. for example: "../logo/logo.jpg".
It's shown correctly on design time but on testing iReport gives me this error.

net.sf.jasperreports.engine.JRException: Image not found : ../logo/logo.jpg

could it be a relative url's problem. That would be terrible becouse I won't know the complete path to the catalog's images.
Post edited by: el_itur, at: 2006/07/19 20:02
el_itur's picture
91
Joined: Jul 18 2006 - 5:10am
Last seen: 16 years 10 months ago
JasperReports does not support relative paths, iReport yes.

JasperReports accepts absolute paths and it looks for a resource on file system first, then in the classpath, so if your images are in the classpath, you can simply refer to them with the name.

An alternative is storing the path in a parameter to have expressions like:

$P{IMAGES_DIR} + "/" + $F{IMAGE_FILE}

Giulio
giulio's picture
71765
Joined: Jan 2 2007 - 4:15pm
Last seen: 3 weeks 2 days ago
But what if you are deploying an application on several sever, and each of this deployment have differents path, for instance Server-A, with win2k, has the app on the drive C:\, and a second server-B, has it on another Drive, and so on,
efebo_abel's picture
Joined: Aug 15 2006 - 2:34am
Last seen: 16 years 9 months ago
Feedback