Skip to main content
    Country/region select      Terms of use
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

Here's my idea of probably the best we can do in the Notes client by way of user-friendly validation. I created a form to demonstrate this:

A Gentler Validation

The situation shown is just after trying to save. The yellow area at the top is a non-scrolling header, visible no matter where you are on the form. It's set to "fit to content," so it's not visible at all unless you have some validation errors (actually it's there but only about 15 pixels tall, and not yellow). When you save, Querysave code does a refresh (to trigger translation formulas and read rich text into the back end), scans the fields to build a list of validation messages, and if there are any messages, writes them into a hidden field, does another refresh to make them display, and displays the text of the first message in a messagebox. There are two reasons for the messagebox. First, the user needs to be alerted that the save they requested didn't happen, and second, visually impaired users will find it more difficult to use the error display area, so they will be grateful for something that screen readers will automatically read to them.

The focus is initially placed in the first field with an error. The user can click on any of the messages to navigate to the field that message is about. There's a limit of six messages we can display at once. If there are more than six, scrolling controls appear above and/or below the message list (depending on your current position in the list). I don't like having a limit, but I can't think of a way to accommodate an arbitrary number of messages.

This is done with six Computed for Display fields (I guess they could be computed text instead but this lets me use @ThisName in their formulas), six hotspots to set focus to a field, and eight or so different hide formulas. It doesn't seem to affect performance noticeably.

I thought about using passthru HTML to build the error list and links, but unfortunately this is only refreshed on open. Also, we do need some limit because if there are a lot of messages, we don't want to take up the whole screen with the error list, leaving no space at the bottom for the user to do the corrections.

This could be improved on if there were also some way to visually highlight the fields that were in error, and to highlight the message pertaining to the current field. I couldn't think of a way to do this that doesn't require you to add a lot of stuff all over the form and in field events. The way it is now, you can take that top bit and use it on any form -- just have to customize the Querysave code for the validations you want to do.

(Actually, it occurs to me now that the Querysave code could start a NotesTimer that periodically checks what field you're in, and updates the error message display to cause the relevant message to be highlighted somehow. I think I'll leave this for someone else to do. If you try it, warning about Native style fields: modifying the back-end document might make Notes forget where the cursor is or erase what you've typed since entering the field.)


  • If you have a non-scrolling header, the Notes client likes to start out with the focus in the header, so none of your editable fields has focus. You can correct for this by designating a field as having default focus (as I did for the Subject field in this case).
  • Since this is just a proof of concept, I didn't take the trouble to over-engineer the code as I normally do. In reality, we should modularize this more, put it on a subform, etcetera.
  • My first approach tried to do the validations using a formula in the computed field in the header. I found out these formulas are evaluated before the fields in the lower part of the form are updated in the formula engine's field list. LotusScript can read their current values; a formula in the header sees the old values from the last refresh.
  • A background color on the form seems to work OK, but a background image is visible only on the header. Any suggestions on how to make that strip vanish completely when not in use, and to get a graphic background on the main part of the form, would be appreciated.
Here's the sample database to play around with: Fancy

Andre Guirard | 21 February 2008 03:38:00 AM ET | Home, Plymouth, MN, USA | Comments (10)

Search this blog 


    About IBM Privacy Contact