Domino Connection : Retrieving Domino documents : Creating new databases using templates
Creating new databases using templates
Domino provides a mechanism to create databases already initialized with forms and views, ready to work. A template is a (usually empty) database with a filename extension NTF. It contains forms and views and other design elements that can be copied to an empty database during creation. VA Smalltalk Domino Connection supports this feature. There is a special directory view available to find all template databases, locally and remote. It works like the AbtLnDirectoryView, but returns only template databases.
To create a new database based upon the common personal names and address database located on your workstation, you will have to perform the following steps. (Make sure you have the database template called pernames.ntf available in your data directory or modify the sample code to us a template this is present on your system).
| templateDatabase newDatabase localConnection |
"Initialize the runtime system"
AbtLnEnvironment startUp.
"Build a local connection"
localConnection := AbtLnConnection local.
"Open the template database"
templateDatabase := localConnection openDatabase: 'pernames.ntf'.
"Create a new database with the name of XTRANAME.NSF
using the names database design"
newDatabase := AbtLnDatabase create: 'XTRANAME.NSF'
via: localConnection
fromTemplate: templateDatabase
inherit: true.
"Display the new databases design on the Transcript window"
newDatabase open.
newDatabase allFormNames do: [ :name |
Transcript nextPutAll: 'All form names:'; cr.
Transcript nextPutAll: name printString; cr.
].
newDatabase allViewNames do: :name |
Transcript nextPutAll: 'All view names:'; cr.
Transcript nextPutAll: name printString; cr.
].
"Close the database"
newDatabase close.
"Shutdown the runtime system"
AbtLnEnvironment shutDown.
The last parameter in the create:via:fromTemplate:inherit: method specifies whether the new database inherits the design changes from the template database.
Note:
Be aware that setting the fourth parameter of the message to true might result in a design change of your database without notice. If someone is authorized to change the template and actually does that, your database will also be changed. If your application relies on the presence (or absence) of certain design elements, it might not work properly after the design change. Set the parameter to false if you do not want to change inheritance.
Last modified date: 01/29/2015