Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7754171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:14:28+00:00 2026-06-01T12:14:28+00:00

I have a ‘small’ problem. In a database documents contain a richtextfield. The richtextfield

  • 0

I have a ‘small’ problem. In a database documents contain a richtextfield. The richtextfield contains a profile picture of a certain contact. The problem is that this content is not saved as mime and therefore I can not calculate the url of the image.

I’m using a pojo to retrieve data from the person profile and use this in my xpage control to display its contents. I need to build a convert agent which takes the content of the richtextitem and converts it to mime to be able to calculate the url something like

http://host/database.nsf/($users)/D40FE4181F2B86CCC12579AB0047BD22/Photo/M2?OpenElement

Could someone help me with converting the contents of the richtextitem to mime? When I check for embedded objects in the rt field there are none. When I get the content of the field as stream and save it to a new richtext field using the following code. But the new field is not created somehow.

System.out.println("check if document contains a field with name "+fieldName);
        if(!doc.hasItem(fieldName)){
            throw new PictureConvertException("Could not locate richtextitem with name"+fieldName);
        }


        RichTextItem pictureField = (RichTextItem) doc.getFirstItem(fieldName);

        System.out.println("Its a richtextfield..");
        System.out.println("Copy field to backup field");

        if(doc.hasItem("old_"+fieldName)){

            doc.removeItem("old_"+fieldName);

        }


        pictureField.copyItemToDocument(doc, "old_"+fieldName);     

//      Vector embeddedPictures = pictureField.getEmbeddedObjects();
//      System.out.println(doc.hasEmbedded());
//      System.out.println("Retrieved embedded objects");
//      if(embeddedPictures.isEmpty()){
//          throw new PictureConvertException("No embedded objects could be found.");
//      }
//      


//      EmbeddedObject photo = (EmbeddedObject) embeddedPictures.get(0);
        System.out.println("Create inputstream");

        //s.setConvertMime(false);
        InputStream iStream = pictureField.getInputStream();
        System.out.println("Create notesstream");
        Stream nStream = s.createStream();
        nStream.setContents(iStream);

        System.out.println("Create mime entity");

        MIMEEntity mEntity = doc.createMIMEEntity("PictureTest");
        MIMEHeader cdheader = mEntity.createHeader("Content-Disposition");
        System.out.println("Set header withfilename picture.gif");

        cdheader.setHeaderVal("attachment;filename=picture.gif");
        System.out.println("Setcontent type header");
        MIMEHeader cidheader = mEntity.createHeader("Content-ID");
        cidheader.setHeaderVal("picture.gif");
        System.out.println("Set content from stream");
        mEntity.setContentFromBytes(nStream, "application/gif", mEntity.ENC_IDENTITY_BINARY);
        System.out.println("Save document..");

        doc.save();
        //s.setConvertMime(true);


        System.out.println("Done");

        // Clean up if we are done..

        //doc.removeItem(fieldName);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:14:29+00:00Added an answer on June 1, 2026 at 12:14 pm

    Its been a little while now and I didn’t go down the route of converting existing data to mime. I could not get it to work and after some more research it seemed to be unnecessary. Because the issue is about displaying images bound to a richtextbox I did some research on how to compute the url for an image and I came up with the following lines of code:

    function getImageURL(doc:NotesDocument, strRTItem,strFileType){
        if(doc!=null && !"".equals(strRTItem)){
            var rtItem = doc.getFirstItem(strRTItem);
            if(rtItem!=null){
                var personelDB = doc.getParentDatabase();
                var dbURL = getDBUrl(personelDB);
                var imageURL:java.lang.StringBuffer = new java.lang.StringBuffer(dbURL);
    
                if("file".equals(strFileType)){
                    var embeddedObjects:java.util.Vector = rtItem.getEmbeddedObjects();
                    if(!embeddedObjects.isEmpty()){
                        var file:NotesEmbeddedObject = embeddedObjects.get(0); 
    
                        imageURL.append("(lookupView)\\");
                        imageURL.append(doc.getUniversalID());
                        imageURL.append("\\$File\\");
                        imageURL.append(file.getName());
                        imageURL.append("?Open");
    
                    }
                }else{              
                    imageURL.append(doc.getUniversalID());
                    imageURL.append("/"+strRTItem+"/");
                    if(rtItem instanceof lotus.domino.local.RichTextItem){
                        imageURL.append("0.C4?OpenElement");
                    }else{
                        imageURL.append("M2?OpenElement");
                    }
                }
                return imageURL.toString()
            }
        }
    }
    

    It will check if a given RT field is present. If this is the case it assumes a few things:

    • If there are files in the rtfield the first file is the picture to display
    • else it will create a specified url if the item is of type Rt otherwhise it will assume it is a mime entity and will generate another url.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a look at one of my websites: moskah.com The problem is that it
Have a simple contact us XPage created. Have server side validation in place that
Have a problem that seems easy on paper but i'm having a big problem
Have some dates in my local Oracle 11g database that are in this format:
I have a reasonable size flat file database of text documents mostly saved in
Have searched the database but need to specifically sum(of hours flown or days off)in
Have a bunch of WCF REST services hosted on Azure that access a SQL
have you ever found a problem when assigning a click event handler for your
Have an app that can use tts to read text messages. It can also
Have such a problem, hope you'll help me.. Can't find anywhere. Here is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.