Manage Learn to apply best practices and optimize your operations.

How to display a Rich Text Field from existing Notes document on the new Web Form

Wouldn't it sometimes be nice to publish some rich text from Notes databases on another Web page?

Wouldn't it sometimes be nice to publish some rich text from Notes databases on another Web page?

Unfortunately, there is no straightforward way to do this. If you just drop a computed rich text field on the form and substitute its content using WebQueryOpen agent, you cannot get the updates shown on the Web page immediately.

Substituting a rich text field with a pass-thru HTML computed text field helps to get the contents of the rich text; however, all the formatting gets lost. So, for a pass-thru HTML it would be better to get HTML directly from the rich text.

There is a technote on the Lotus Support site about "How To Access HTML in a Rich Text Field Using LotusScript"( for the Release 5.0.3 and later). In a few words, you need to enable "Store contents as HTML and MIME" option on the field properties panel. But it seems they tested just the very simplest case so I found several drawbacks: 1.It breaks one Rich Text field into several MIME fragments so their example just returns "This is a multi-part MIME document." 2.I had to traverse all the MIME parts of the field. When I finally get to the text part, I just found it was base64-encoded so no HTML was available.

If you cannot read rich text directly, maybe it's possible to force Domino to serve it as HTML content? You could create a string variable, read a Web page into it then drop what's unnecessary there and assign that string to a computed text field.

Unfortunately again, formula language or LotusScript are of little use here. @URLOpen simply doesn't work in this context, and I couldn't find any appropriate LotusScript objects/methods/functions to accomplish this task.

Here is where new technologies really help. Fortunately, a code to achieve this goal is simple enough. Actually, it's a compilation from Designer R5 help and Sun's Web tutorial code fragments. Because the documents I read rich text from don't contain much info but the RTF, I didn't even try trimming the string buffer here. Maybe people who know Java I/O better can polish this fragment eliminating the inefficiency of the string buffer. However, it works fine for me now. It can be easily adapted for delivering different documents under different conditions - a sort of dynamic drive.

Solution:

1. I assume here that a Notes document with an RTF content in it exists, and an URL http://www.domain.com/dbName.nsf/ViewName/DocName?OpenDocument points to that document.
2. Create a new form with computed text field [ProNews].
3. Mark the field as Pass-Thru HTML
4. Create the Java agent [jarticle] for WebQueryOpen event as usual (Shared, run manually from Action menu, Run Once). Enter the following code in the programming pane.
5. Save the agent
6. For the WebQueryOpen event of the form enter the following formula : @Command([ToolsRunMacro]; "jarticle")


import lotus.domino.*;
import java.net.*;
import java.io.*;

public class JavaAgent extends AgentBase {

	public void NotesMain() {

		try {
			Session session = getSession();
			AgentContext agentContext = session.getAgentContext();

			// (Your code goes here) 
              
               Document doc = agentContext.getDocumentContext();  // get the document context
               
              // Let's read a Web page
              URL pageX = new URL("http://www.domain.com/WebArtic.nsf/ViewName/DocName?OpenDocument");
               BufferedReader in = new BufferedReader(
               new InputStreamReader(
               pageX.openStream()));



              String inputLine, allLines;
              allLines = "";

              // accumulate the whole page in the allLines
              while ((inputLine = in.readLine()) != null)
                  allLines = allLines + inputLine; 

             in.close();    // close the URL
             
             // Substitute computed text field value with conversion from UTF-8 to ordinary Web encodings.
              doc.replaceItemValue("ProNews", new String(allLines.getBytes(),"Windows-1251"));

    		} catch(Exception e) {
			e.printStackTrace();
		}
	}
}

Dig Deeper on Domino Resources

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close