Step by Step description how to build the sample
Make sure you have performed the initial steps to rebuild the samples before you proceed (see
Preparations for Version 4.5 samples). Create a new visual part. If you have not already done so, create a connection specification named MyDiscussionSample for the local \vasample\vadis45.nsf database.
1. Select Domino Parts from the parts palette and add a Domino Form part to the free form surface. Double-click the form part to open the settings page. From the Alias Name dropdown listbox select the MyDiscussionSample connection alias. The form part is now reading structural information about the sample database. From the Available Forms dropdown list select Main Topic. Select the Error Reporter Creation check box to make the part ready for automatic error handling.
2. Select OK to close the settings page. You have now configured the form part to represent the Main Topic form of the discussion sample database. Rename the from part to MainTopicForm.
3. Connect the aboutToOpenWidget event of the main window to the open action of the form part to initialize the part during runtime. Connect the aboutToCloseWidget event of the main window to the close action of the form part to free all resources when the program ends. Tear off the database attribute of the form part and place it on the free form surface. It is convenient to have this tear off for writing scripts later on.
4. Tear off the formName attribute of the form part. The formName attribute contains an instance of an object that holds the Domino forms primary name and its alias names. Connect the primary attribute of the formName attribute of the form part with the title attribute of the main window to display the forms name.
5. Tear off the currentNote attribute form the form part an place it on the free form surface. This object will represent a Domino document to be edited with the form part. Add entry fields to the main window for all interesting attributes of the Domino document and a multi line edit field for the body field (in particular add fields for Subject, From, Category and Body). Set the converter attribute of each entry field to the appropriate value: if it is a simple text field, select Text, if it is a multiple value field (like Category) select Text List. In case of a multi line edit field, use RichText. Connect the object attribute of each entry field to the corresponding attribute of the currentNote tear-off. The currentNote tear-off will provide you with all attributes that represent items in a Domino document that is created with the given form. Connect the object attribute of the multi line edit to the body attribute of the currentNote tear-off.
6. Now add four buttons to the window named: Available Categories, New Note, Store Note and Cancel. Connect the clicked event of the New Note button with the newNote action of the form part. Clicking this button will make the form part create a new document at runtime. When the sample application opens, no document is created by default. You have to use the New Note button to create a document prior to entering data.
7. Connect the clicked event of the Store note button with the storeNote action of the form part. Clicking this button will make the form part save the current document at runtime. Connect the clicked event of the Cancel button with the closeWidget action of the main window.
8. To enable the Available Categories function you need to create a script. Change to the script editor and add the following method:
categoriesSelection
"retrieve all available categories"
| db view categories |
db := (self subpartNamed: 'MainTopic Form') database lnDatabase.
^db isNil
ifFalse: [ view := (db openViewRebuild: 'By Category').
categories := view root children collect: [ :e | e category ].
view close. categories
]
ifTrue: #() ].
9. Now change to the public interface editor and add an attribute named categoriesSelection. Set the Get selector and the Change event symbol to categoriesSelection. Set the Attribute data type to OrderedCollection and the Attribute contents data type to String. Save theses settings.
10. Change to the composition editor. Add a second window named Available Categories to the free form surface to display the available category values. Drop a list part into the new window. Connect the clicked event of the Available Categories button on the main window to the openApplicationModalWidget action of the new window. By using this action you implicitly disable the main window for the time the available categories are displayed. Connect the openedWidget event of the Available Categories window with the items attribute of the list in this window. Now you have to supply the parameter.
11. Right click on the connection and connect the value attribute of the connection to the categoriesSelection attribute of the main window. Add a button named OK to the new window. Clicking this button will set the selected categories from the Available Categories window to the Categories entry field on the main window. To achieve this, connect the clicked event of the OK button with the object attribute of the Categories entry field in the main window. Supply the parameter from the Available Categories window: connect the lists' selectedItem attribute to the value attribute of the connection. Finally connect the clicked event of the OK button to the closeWidget action of the Available Categories window.
12. You are now ready to test the part. If anything does not work as expected, compare your work with the sample code in AbtNotesDemoApp45
Last modified date: 01/29/2015