Your Development & Design Resource

XPages Primer: Creating a New Contact in a Domino Directory

IBM Lotus Notes Domino 
XPages One of the greatest benefits of using IBM Lotus Notes Domino XPages is that it naturally allows for the separation of User Interface and Target DataStore. To illustrate, we'll use an XPage to create a simple User Registration form for a Domino Directory!

To kick off this process, we'll create a new Domino Directory (local is fine, no need for a server for this demo build). I named my new local Domino Directory aldir.nsf. Next, I create a new blank NotesDatabase, which I named alsite.nsf. We'll be adding our XPages Design Element in the alsite.nsf, which will communicate directly to the aldir.nsf Domino Directory. Again, running this on local is fine...

The XPage, which I'm naming index.xsp, will consist of -- for the purposes of this demo -- a simple user registration form.

The index.xsp Source Code:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xp:view xmlns:xp="">
  4.  <>
  5.   <xp:dominoDocument var="userreg" databaseName="aldir.nsf"
  6.   formName="Person">
  7.   </xp:dominoDocument>
  8.  </>
  10.  <fieldset class="userreg">
  11.   <label for="firstname">First Name</label>
  12.   <xp:inputText id="firstname" value="#{userreg.firstname}">
  13.   </xp:inputText>
  14.   <br />
  15.   <label for="lastname">Last Name</label>
  16.   <xp:inputText id="lastname" value="#{userreg.lastname}">
  17.   </xp:inputText>
  18.   <br />
  19.   <label for="internetaddress">Email Address</label>
  20.   <xp:inputText id="internetaddress" value="#{userreg.internetaddress}">
  21.   </xp:inputText>
  22.   <br />
  24.   <xp:text escape="true" id="type" value="#{userreg.type}"
  25.   rendered="false">
  26.   </xp:text>
  28.   <xp:button value="Register" id="userreg_submit">
  29.    <xp:eventHandler event="onclick" submit="true"
  30.    refreshMode="complete">
  31.     <xp:this.action>
  32.      <xp:actionGroup>
  33.       <xp:modifyField name="type" value="Person">
  34.       </xp:modifyField>
  35.       <xp:saveDocument></xp:saveDocument>
  36.      </xp:actionGroup>
  37.     </xp:this.action>
  38.    </xp:eventHandler>
  39.   </xp:button>
  40.  </fieldset>
  42. </xp:view>

The above code -- sans any styling -- creates the following fully-functional XPages-based Form:

Simple XPages User 
Registration Form

Lines 4-8 define our target Data Source, which is our aldir.nsf Domino Directory.

The only other real gotcha to point out here is at line 33, where the Register button uses an actionGroup to first set the non-rendered type InputField to Person before submitting the request to create a new NotesDocument in the aldir.nsf Domino Directory. That is simply due to the target Domino Directory Person NotesDocument requiring that the type NotesItem be set to "Person" before it will be displayed in the People View. The type NotesItem has no particular functionality specific to the XPage User Registration Form.

To really make this a reusable solution, you can take the XPages XML markup above and create a Custom Control Design Element, which could be used by any other Custom Control or XPage Design Element in your NotesDatabase Design.

See my post on XPage Custom Controls in IBM Lotus Notes and Domino from the other day for more details.

... and that's it! I can use this User Registration Form (or via a Custom Control) in my XPages-based application to create NotesData in other NotesDatabases with literally zero modifications to the target NotesDatabase design.

Amazingly powerful stuff here, and certainly something that while doable using traditional IBM Lotus Notes and Domino development techniques, XPages makes it a simple RAD operation!

About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.

More from is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.