Validating rich text

Validating rich text

From "Rich text programmability for Notes R5 applications" by Andre Guirard, who works from Lotus Development's ISV Technical Consulting group, which originally appeared in the May/June 2000 edition of The View

.

Notes developers have long had to work around the problem that, in Notes, there is no way to make sure that the user enters a value in a rich text field before saving a document. There are workarounds for specific kinds of validations, but until R5, there hasn't been a general-purpose way to validate rich text field contents.

With R5, it's possible to write a Querysave event that reads the current value of the rich text field. To do this, you have to refresh the form using the NotesUIDocument.Refresh method with an argument of True, as the code below does. This code, created as an example, doesn't actually do any validation; it just displays the text it reads from the rich text field.

Sub Querysave(Source As Notesuidocument, Continue As Variant)
	   Dim ws As New notesuiworkspace
	   Dim uidoc As notesuidocument
	   Dim doc As NotesDocument
	   Dim rtf As Variant
	   Set uidoc = ws.CurrentDocument
	   uidoc.refresh True
	   Set doc = uidoc.Document
	   Set rtf = doc.GetFirstItem("Body")
	   Messagebox debugstr(rtf.text)
End Sub

The debugstr function in this code takes any value and returns a text description of it in a message box. It's not part of the LotusScript language; it's a function the author wrote that can be pasted in whenever one needs to display a value for debugging purposes.

You can try this yourself in the sample database available at The View's Web site: http://www.eview.com/eview/view.nsf/2d0e694750acb0ae8525668000517be3/f40ef674a562b18c852568d30057eee4?OpenDocument

Select Create-Validate Rich Text. Enter some values in the table that opens in the Validate Rich Text document.

When you use the Text property or the GetFormattedText method of a NotesRichTextItem, tables are presented as columns of text separated by tabs. So there's a "tab" character (in LotusScript, Chr$(9)) between each column, and the "newline" sequence, carriage return and line feed (Chr$(13) and Chr$(10)), at the end of each row.

This can get ambiguous if the person editing the document enters tabs or newlines in the table cells. If you were trying to validate the table contents and you looked for the "newline" sequence to spot the end of a row, then "20 30" would look like two different rows to you. So you might not be able to tell exactly how the table is formatted. But for validation purposes, you don't care -- just reject any input that doesn't match what you expect.


This was first published in May 2000

Dig deeper on Domino Resources - Part 5

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWinIT

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 ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.UK

Close