Thursday, February 23, 2012

Image URL in XPages using Notes client and browser

In Java Charts, one of the users reported that charts were not visible in Notes client. The charts (images) are basically being generated using the XAgent technique, and you will face the same problem if your image is being generated using XPage.

To understand what exactly is happening lets take help of an example. Say you have XPage with following code snippet which displays an image using javascript formula. (actn005.gif is present in the current database as image resource.)

When the XPage is previewed in Notes client the source shows up something like this:

while in browser source is like this:

Notice the difference! In Notes client /xsp/ is inserted in the URL. The image displays in both cases without any issues. But if you have a XPage which renders image, lets call it - XPage_Rendering_Image.xsp,  and you add that name in the image URL then your source would be:

And this will fail, as their is no XPage on that path. So to get around this problem, you can either add the <img> tag directly inside your XPage source:

Or if you have bit more complex calculation then you could create a computed field with content type as HTML and create <img> inside it:

Why is /xsp/ added to path? Well, the XSP path part in the Notes client is needed so the local web server can recognize that it is to be rendered by the XSP engine and not a classic client part. In my opinion I would consider this one as a bug and I am not alone on this one.

No comments:

Post a Comment