March 1, 2011

Solved:Display picture from Rich Text Field with XPages


Im having a Form where I have a Rich Text Field(lets call it imageField) added there to hold an image. The user of the Form will directly copy an image into the imageField , not the location of the image, THE image will be copied into the field.

When I then later try to display this image on a Xpage nothing comes up..

Google wont help me with this particular problem either. Anyone out there know how to do this?

SOLVED:
As Ben over at My Comfy Chair pointed out this is in fact quite easy to solve.

Start by making the Rich Text Field save as HTML and MIME. After that you simply refer to the field in the src part of the img tag:
src=\"myView/"+itemInView.getDocument()+"/FieldName/M2?OpenElement"

Worked like a charm for me! Thanks alot Ben!

6 comments:

  1. Sure, you just need to set the imageField to save as HTML and MIMEm, then reference the mime part in your img src. It will have a format like:

    http://server/MyDatabase.nsf/viewunid/docunid/imageField/M2?OpenElement

    ReplyDelete
  2. Thank you Ben! Will try this out right away!

    ReplyDelete
  3. Worked like a charm! Thank you Ben!

    ReplyDelete
  4. Can you please explain how to do this? I'm quite new in Xpages and i''ve been struggling for two weeks to get it to work... Tnx
    What i need is this, when i create a document i need an image to be added just like the one you have added here, or (by choice) to be at the end of the document. Afterwards i need an option to change the image in the document or simply delete it. Thank you!

    ReplyDelete
  5. Please help me in retrieving value of a rich text field and display it in another richtext or a computed field

    ReplyDelete
  6. First of all, you can't use img in Xpages, and src won't work with xp:image

    ReplyDelete