Jasper Report: path in foundset reports are for the client

Hi everybody,

I have several Jasper reports in my solution. They all include the logo of the company on them.
Apparently, as far as I know, you cannot embed pictures into your report file and instead you have to provide a path to the picture file in the report.

So currently I have the picture on the server and each report contains the path to this picture.
This works fine on all the reports, except the only one I have which uses a foundset instead of an SQL query to provide data. When I try to generate this report from the Smart Client it looks for the picture on the client machine instead of taking it from the server. As a result the report generation fails because it couldn’t find the picture.

Is that normal? :shock:

If I’m not wrong a foundset based report is generated where the servoy client is executed (client machine in SC and server machine in WC), because of this the report looks for the logo in the client machine from the SC.
You could use a global var to show the logo in the foundset based report.

Hi,

I understand what you mean. But I think it should be possible to make it behave like using an SQL query because there is no link between the SQL or foundset and the URL to the picture and the way to retrieve it. On both cases you are on the client when you run the report.

Anyway, I have tried to use a global variable as you advised me but I can’t manage to make it work. My global is of type MEDIA. In the report I have created a Field called “globals.my_picture”. I have placed a picture (same name as in my solution) on the report and put “$F{globals.my_picture}” as image expression and tried several Expression class but none seems to work.

It’s the first time I try to use globals into a report so I don’t know If I’m doing it the right way. :roll:

Hi,

This works for me:

for the field definition
Field Class: java.lang.Object

for the image properties:
Image Expression: net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte)$F{globals.my_picture})
Expresion Class: java.awt.Image

Hope this helps

Your code works like a charm! :)

Did exactly what you wrote and now it’s working perfectly.

Many thanks Victor :wink: