Bug in getting RichTextItem?

I cannot retrieve a rich text item from an Xpage server script.

As for the documentation, the item name is NotesRichTextItem, not RichTextItem as the documentation says. The method shown in the documentation won’t even validate in the DDE Javascript editor.

This is the closest I can come:

var rt=new NotesRichTextItem(doc.getFirstItem(‘Body’));

Which returns the following server error:

Exception

Error while executing JavaScript computed expression

Script interpreter error, line=18, col=54: Cannot construct an instance of class ‘NotesRichTextItem(lotus.domino.local.Item)’

Looks like a bug to me but I’m open to suggestions.

Subject: Have you tried

var rt_as_html = dominoDoc.getValue(“Body”);

One nice thing this should do for you is hide whether the item is stored as MIME or CD, so you don’t have to code your features to work with the Java/Corba classes ( RichTextItem and MIMEEntity ) for both rich text storage types.

dominoDoc is designed to be managed in a JSF lifecycle. So calling dominoDoc.setValue(“Body”, “Hi”); updates a JSF cache - not the document in the nsf. dominoDoc.save() will commit your changes, and the resulting rich text will be stored as MIME.

(This can be a very expensive call, if your document is in CD format and has attachments, so be smart and only call it once if you choose to use it!)

You can still use the Java/Corba classes, making calls like doc.getFirstItem(‘Body’); as you have done in the past. But expect trouble if you mix the two - any changes made through thee Java/Corba backend class api will bypass the JSF layer, which xpages is using to cache all changes. The cache won’t know it’s out of synch with the nsf until it goes to save your JSF data - then it has to raise an error / generate a conflict document.

Subject: I did but…

I got HTML back but with spaces inside the tags i.e. < DIV >.

I chose to store the RichText field as HTML/MIME in the field options on the form.

Maybe I’ll try storing in CD instead and see what happens. My plan B is to create a computed ‘HTML’ field on the form. That field (also RichText) works fine when treated as a plain text field in script providing I put HTML in it.

Thanks,

Ken