logo

Ugly Son of a Hack

Ok, here goes. How to store Rich Text that you can edit in the Notes client and in the browser (using a third-party plugin) while still allowing files to be uploaded that don't display as tables in the field. A very specific problem but not uncommon.

The only way I've found to get this working involves the use of three Rich Text fields - two real and one faked. In the form below, you can see how they are layed out. FileStore and Body are both Rich Text fields and both are set to use the Java Applet. Both are also hidden from the browser using a style setting of "display:none" in the HTML Attributes. Both are sent to the browser in edit mode whilst in read mode the FileStore field is completely hidden from the browser. The third field doesn't exist on the Notes form and is simply used by the browser to display the editor. The JavaScript you can see it what turns the plain textarea element in to a fully functional, customisable, editor.

Grab of Notes form in design mode

When the page loads, the content of BodyTemp is loaded from the editor applet associated with the Body field, using its getText() JavaScript method. Before the form is submitted the content of BodyTemp is sent back to the Body field for storage in the document.

Why/how does this work? Well, with both the applets set to not display by the browser, they are available to JavaScript but don't load in the browser (which means you don't have to wait three weeks for them to load). So we can get and set the HTML stored in the Body field. Because we have another field that's before Body on the form, all files are moved here. Because this field is completely hidden in read mode, we never see the tables that indicate file attachments.

I hope that makes sense. If not ask and I'll try and make it as clear as possible. What I won't do is recommend using it. It might be the only way I've found to solve a project requirement but there's no way I can implement it. I wouldn't be able to sleep at night!

Comments

    • avatar
    • Neil
    • Wed 12 Nov 2003 05:18

    I started to integrate HTML area into Domino also last week, and have just run into the problem you mention... So thanks for a very neat fudge !

    The other thing that I have a pro blem with is the URL's to the html pages/forms and images. I cannot download these into the html directory, and need to store them in the Domino database..

    This is fine when you open the form, but when you edit a document, because you access it through aview the relative URL's do not work.. Have you found a way around this issue?

    Thanks

  1. Avoid relative URLs. That's a rule I'm slowly implementing because A) things can break easily, as you note and B) with my use, specifically, if it's in an article that goes in the rss feed, the relative URL's don't work for people viewing content in their aggregator.

    With @WebDBName in R6 it's easier to include this, but you may have found a default Domino functionality that is going to assume relative URLs are always ok. :-\

    Jerry

  2. Set a "static" base href for all of your code in the htmlarea. Instead of the files pointing to "images/" set them to "{Link} etc.

    (In the htmlarea.js simply replace the following:

    this.imgURL = "images/";

    this.popupURL = "popups/";

    )

    To do this with a dynamic static base href in the code, turn the pages from htmlarea into pages (I used forms with the blank navigator/$$Navigator for trick) and set the base link like this:

    "{Link}">Link} + @GetHTTPHeader("Host") + "/" + @ReplaceSubstring(@ReplicaID;":";"") + "/images/"

    As I've said, I use the form/navigator trick for this and simply create a CFD field called "hBase" set to the following:

    "{Link}">Link} + @GetHTTPHeader("Host") + "/" + @ReplaceSubstring(@ReplicaID;":";"") + "/"

    Now, my htmlarea.js looks like this:

    this.imgURL = "<computed text>images/";

    this.popupURL = "<computed text>popups/";

    HTH,

    -Chris

    • avatar
    • Neil
    • Wed 12 Nov 2003 10:25

    Thanks for the solution, I figured I would have to go down that sort or route, was trying to keep all the .js files as resources, but pages is the best solution. Many thanks for the code that will same me some valuable time.

  3. This tip might be useful: 'Hiding file attachments when displaying a form on the Web'.

    {Link}

    • avatar
    • Charles
    • Fri 12 Dec 2003 13:40

    Hi,

    HTML area not working with Mozilla and best firewall (block popup windows,etc.....).

    Wow - where is best design ?

    Ciao Charles

  4. Jake, you've made my developer life so much more simple!

    You mention that attached files via the web are automatically put in the FileStore field. This is wonderful news! I found that Domino puts the files into the first Java Applet displayed rich-text field on the form, whether or not the rich-text field is shown.

    Lotus Notes users are used to putting attachments into rich-text fields and they don't like finding their attachments at the bottom of the document after the document has been edited using a web browser. This technique keeps the attachments in the rich-text field!

    Now, does anyone have any ideas on how to provide icons for the attachments without registering the relevant applications on the domino server?

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Thu 11 Dec 2003

Share This Page

# ( ) '

Comments

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