The Ultimate Domino Web Editor

Don't worry. This entry starts off looking like a rant but ends with some really good news.

No sooner yesterday had I written this long-winded rant at Lotus than I had been through a load of forms and enabled the Java Applet on them. Things were working ok and I was resigned to the fact that this was the way it had to be. Then I added a few File Upload Controls to the forms. Yet another problem to deal with! Rich Text fields using the Java Applet "absorb" the attachments on the web. Whether or not the file has anything at all to do with the first applet-field on the form doesn't seem to matter. To get round this I have had to hide (style=display:none) another Editor Applet at the top of the form, called "Attachments". At this point I was ready for writing another rant to vent my anger at how ridiculous it all is. Then came some good new that had a lovely calming effect on my soul.

In yesterday's post I mentioned that all we needed was:

a way to programatically set the MIME type of the field to text/html instead of text/plain

This, effectively, is what the code David Schmidt posted in response does. I'm not exactly sure how it works, but it does. And that's all I care about for now. The code is run during the WebQuerySave event of a field with a normal RichText field on it that contains HTML code. When the resulting document is opened to read, the code is sent to the browser as HTML rather than plain text. Brilliant. it may be a hack of sort but it's not half as bad as the other hacks I've seen or been using. Here's the code:

Dim vWebSession As New notessession
Dim vThisDatabase As notesdatabase
Dim vThisDocument As notesdocument
Dim vRichStyle As NotesRichTextStyle
Dim vRTItem As Variant
Dim vHTMLCode As Variant

Set vThisDatabase = vWebSession.CurrentDatabase
Set vThisDocument = vWebSession.DocumentContext
Set vRichStyle = vWebSession.CreateRichTextStyle

Set vRTItem = vThisDocument.GetFirstItem( "Body" )

If ( vRTItem.Type = RICHTEXT ) Then
vHTMLCode= vRTItem.GetUnFormattedText()
Call vThisDocument.RemoveItem("Body")
Set vRTItem = vThisDocument.CreateRichTextItem( "Body" )
Call vRTitem.AppendStyle( vRichStyle )
Call vRTitem.AppendText(vHTMLCode)
End If

Consider the simple form below, on which I've been testing this code with my favourite cross-browser Rich Text editor - HTMLArea 3. The rich text field ("Body") isn't marked as PassThru with any hacks, nor does it use the Java Applet. Yet we can use it to store HTML by simply running the above code on the field, each time it is saved.

Domino Form

You can test the form for yourself if you like. Unlike hacks I've used in the past this allows you to store no limit of HTML. Well, I've tested it up to 200kb!

I know I said the RT field is not pass-thru but you may have noticed there is some passthru on the same line as the field. The reason for this is that HTMLArea doesn't like unclosed <p> tags, whereas Domino just loves to scatter them about willy-nilly.
Making all lines, up to and including the Body field, passthru prevents this ugly code and any errors.

There's more to be said about HTMLArea than I can fit in one blog. The form I linked to is called "simple" for a reason! Expect more examples, an article and a demo database. Thanks to David Schmidt I think we could well have found the ultimate Domino web editor for Rich Text fields!

Note: If you can't wait for the demo database, drop me a line and I'll send you one over...


  1. Hi Jake,

    I am a little bit confused. (In the pinball game of life my flippers are little bit further apart than everyone else) :-)

    Is it that you dont want to use the Java Applet rich text Notes editor because attachments show up in the first rich text field on the form? Sorry if Im being a bit thick..


    • avatar
    • Jake
    • Thu 1 Jul 2004 05:29 AM

    Allen, there are numverous reasons I don't want to use the Java Applet. See Tuesday's post for a list of reasons. The fact that they screw-up file attachment handling is yet another reason.

    Maybe I confused things by talking about the files and HTMLArea in the same post. The files I just *had* to rant about to get it off my chest and the HTMLArea thing is something I am excited about and want to pass on.

    The thing with writing blog entries is that it always make perfect sense to the author ;o)

    • avatar
    • Derek Atkinson
    • Thu 1 Jul 2004 08:04 AM

    This is amazing. What looks like cracking code from David, delight from Jake and a memorable quote from Allen!

    • avatar
    • Stu
    • Thu 1 Jul 2004 08:32 AM

    Jake is amazing, he welds Big Brother power. Don't remove people's entries because it does not fit into your blog or days rant.

    Is there someone reading this that may beable to help me with Java View applets and the onreadystaechange event.

    • avatar
    • Jake
    • Thu 1 Jul 2004 08:36 AM

    Stu. I will do what the hell I like! If you want help with a view applet go to the forums.

  2. Simply Brilliant. Cheers!! to David and Jake. One ugly beast of a problem is finally laid to rest.

    • avatar
    • Stu
    • Thu 1 Jul 2004 09:11 AM

    David, can you give me your email address, so I can discuss the onreadystatechange offline. It will keep grumpy Jake happy.

    • avatar
    • Dave
    • Thu 1 Jul 2004 10:14 AM


    You act like your entitled to have someone else do your work for you.

    Grow up! If you want free advise try being respectful and gracious. Otherwise call Lotus support!

  3. Jake -

    I'm confused. Is the object of the game just to get Domino to render HTML entered in a rich text field? If so, what's wrong with the square bracket trick (e.g. [<h3> My heading</h3>]?

    Or are you trying to get HTML marked-up output without forcing users to enter HTML marked-up input?

    I hope the question is clear - just trying to phrase it is making my head spin...


    • avatar
    • Jake
    • Thu 1 Jul 2004 11:18 AM

    No worries Sean. It's a confusing topic.

    There are two problems with marking the field as PassThru. One is that it's easy for the user to accidentally cancel passthru mode by entering a stray ] bracket. The other problem is that I've seen fields marked up like this misbehave and enter stray "@NewLines" in to the HTML. This is ok until the new line happens within an opening/closing tag and things go very wrong!

  4. Ok, this does look promising. I know your not using the client Jake, but do you know what the saved richtext looks like from the client?

    I'm living in a mixed client (web/client) world and wonder if this is truly the holy grail we've been looking for?

    • avatar
    • Jake
    • Thu 1 Jul 2004 11:57 AM

    I hate to disappoint Lance but this ain't no grail! For a mixed environment there is only really one solution and that's to do it the way Lotus want you to.

    If you view one of these HTMLArea pages in the client you'll just see HTML code. Even with "Render PassThru in Client" ticked and even with the field marked as passthur explicitly on the form. A shame really.

    • avatar
    • Doug
    • Thu 1 Jul 2004 12:30 PM

    Lance, unfortunately, I too am in a mixed environment for the predominant application that I work on.

    I have tried many different methods of translating documents between the two clients. I have to say that I definately understand your pain and am willing to share what I have tried.

    I wanted to give another thank you to Jake and David for this. My web only applications will benifit greatly from this.

    • avatar
    • Debbie
    • Thu 1 Jul 2004 12:42 PM

    Can I ask a stupid question? (Ok, that wasn't it ;-) ) Is that just for web only access databases?

    I keep struggling trying to figure out how to get the attachments from the client in to work on the web and vice versa.

    • avatar
    • Debbie
    • Thu 1 Jul 2004 12:44 PM

    Oops, sorry, my browser hadn't refresed with those previous posts. Just ignore me, it's been a long day. :P

    • avatar
    • Sas
    • Thu 1 Jul 2004 01:39 PM

    Just made neet enchantment. Now it is properly displayed in the Notes client as well. You cannot edit it, since it will remove html but you can see the same way like in the brouser

    • avatar
    • Sas
    • Thu 1 Jul 2004 01:42 PM

    Jake, I'll send you utdated database with coding that allows viewing on Notes client side as well. Trying to find solution for editing as well (might be impossible)

    • avatar
    • Sas
    • Thu 1 Jul 2004 01:51 PM

    Actually made it to work almost COMPLETELY!!!!

    • avatar
    • Sas
    • Thu 1 Jul 2004 01:53 PM

    Yes it working!!! (sorry for exitement)

    • avatar
    • Jake
    • Thu 1 Jul 2004 02:21 PM

    It's good to see somebody else getting exctied Sas. Send over the DB and I'll pass on the news to all the others.

    • avatar
    • Sas
    • Thu 1 Jul 2004 02:38 PM

    On its way. Now I am working on the attachments piece

    • avatar
    • Sam
    • Thu 1 Jul 2004 02:49 PM

    Jake, could I get a copy of that demo database? It just so happens I was agonizing over the very same problem you mentioned, WRT rich text fields "absorbing" attachments.

    I couldn't see a way to upload files or add an upload control. Is it there and I'm just missing it, or is it something that still needs to be developed? If it's the latter, I'll be happy to do it -- I just need to know.


    • avatar
    • Sas
    • Thu 1 Jul 2004 02:52 PM

    I do not understand what the problem with the attachments? Works fine for me. Even with Java richtext :))))

    • avatar
    • Tom
    • Thu 1 Jul 2004 05:36 PM

    Great stuff!!!!

    Thanks Jake

    • avatar
    • Sas
    • Thu 1 Jul 2004 09:21 PM

    Update. Looks like all pieces finally works as designed :)

  5. hi Jake

    Any chance you can mail me db? - Would like to see if I can get a version working which allows client editing as well without messing stuff up.

    • avatar
    • Jake
    • Fri 2 Jul 2004 05:27 AM

    We're almost there with the Notes + Web editing but I'll mail you one over anyway Steve to see what you do.

    • avatar
    • Sas
    • Fri 2 Jul 2004 07:00 AM

    Ok guys, its done. Notes+Web+Attachment support. If you can't wait for Jake to put up full article just drop me a line

  6. Could you please send me a the demo database to my e-mail?

  7. Could you send me a demo of the database to my email

  8. Hy!

    I am interested in that database where you can edit content in Notes and Web. thank you in advance:)

  9. Is there any change that I can get a copy of the demo database created that allows editing of rich text fields in both Notes and the Web.

    This has been an area of frustration for a lot of developers and you might consider adding a download link to this database on your blog.


Your Comments


About This Page

Written by Jake Howlett on Thu 1 Jul 2004

Share This Page

# ( ) '


The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content