Domino Connection : Samples for Domino and Notes Version 4.5 : Using a view iterator part : Step by Step description how to build the sample
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. Add a Domino View part from the parts palette and drop in on the free form surface. Rename the part to CategoryView. Configure the view part to represent the By Category view of the database represented by the MyDiscussionSample connection spec.
2. Tear off the viewName attribute of the view part and connect the primary attribute of the tear-off to the title attribute of the main window to display the view title in the window caption at runtime. Connect the aboutToOpenWidget event of the main window to the open event of the database view to open the view part whenever the window is opened. Connect the aboutToCloseWidget event of the main window to the close event of the view part to close the view part when the application will be closed.
3. Tear off the iterator attribute of the view part. From the iterator tear off the selectedRow attribute which represents the current position (and current document) during navigation The iterator offers the following protocols: nextPeer, previousPeer, parent, child. Using these protocols you can walk through a hierarchical structure like a categorized Domino view.
4. To do this, you need to supply four buttons to control the navigator. Label these buttons: Next, Previous, Parent, and Child, and connect their clicked events with the respective actions on the iterator part (for example the clicked event of the Next button with the nextPeer action of the navigator). To avoid out of bounds navigation, you have to create some enable/disable logic for the buttons.
5. Connect the enabled attribute of the Parent button to the iterators hasParent attribute - so if there is no parent, you will not be able to navigate upwards. Connect the enabled attribute of the Child button to the iterators hasChildren attribute - so if there is no child, you will not be able to navigate downwards. To protect the Next and Previous buttons you have to do some scripting. Switch to the Public Interface Editor and add two attributes named: nextPeerExists and previousPeerExists. Set the Get selector to nextPeerExists (and previousPeerExists respectively), do not set a Set selector, set the Change event symbol to nextPeerExists (and previousPeerExists respectively) and finally set the Attribute data type to Boolean. Create another attribute named iterator. Use the Add with defaults button to create the attribute specification. Use the File menu to select the Generate default scripts option and generate the instance variables and the accessor methods. Switch to the Script Editor and change the nextPeerExists method to appear as follows:
nextPeerExists
"Return the value of nextPeerExists."
|it|
it := self iterator.
it isNil '
ifTrue: [ ^false ].
^it peerIndex numberOfPeers > 0
Add the following code to the previousPeerExists method:
previousPeerExists
"Return the value of previousPeerExists."
|it|
it :="self" iterator.
it isNil
ifTrue: ^false ].
^it peerIndex > 1
Also add a method containing the following code:
updateExisting
"perform some notifications"
self signalEvent: #nextPeerExists.
self signalEvent: #previousPeerExists.
6. Now switch back to the Composition Editor and do the following: Connect the enabled attribute of the Previous button to the previousPeerExists attribute if the main windows. Connect the enabled attribute of the Next button to the nextPeerExists attribute if the main windows. Also connect the self attribute of the iterator part with the iterator attribute of the main window. Finally connect the peerIndex event of the iterator with the updateExisting script of the main window.
7. Add a button labeled Update. Connect the clicked event of the button with the update action of the viewPart to reset the iterator on demand.
8. As navigation with the iterator part is essentially non visual, you need to give the user some information about their current position in the hierarchy of categories and documents. Add three static texts to the window. They will be used to display the following:
a. The index position of the current tree node in its hierarchy level
b. The number of same level nodes
c. The number of children of the current node
9. Connect the numberOfChildren attribute of the iterator to the respective static text's object attribute. Connect the numberOfPeers attribute of the iterator to the respective static text's object attribute. Connect the peerIndex attribute of the iterator to the respective static text's object attribute.
10. Add an entry field to the main window to display the current category (respectively the category item of the selected document). Connect the currentCategory attribute of the iterator part to the object attribute of the entry field.
11. The selectedRow part has information available not only about its' current category, but if the underlying object actually is a document, it has some information about the document's summary buffer (for a discussion of summary buffers, see the Domino Connection documentation). To display this information add some entry fields to the window and connect each of the $XXX attributes to the object attribute of one of the entry fields. The strange names of these attributes come from the column names of the Domino view- they are internal names used for programming only.
12. To complete the sample you need to add a form to actually display the documents that you reached during your navigational steps. We can reuse a part you have built during one of the previous samples: Using a form part - but we have to promote a feature to integrate it into our current application. Open the sample part that uses a form part on the discussion database (or use the AbtNotesDemoForm45) and switch to the Public interface editor. Promote the editRow: action of the form part contained in this sample and name it FormPartEditRow:. Save the form part sample and return to the current application.
13. From the Options menu select Add part and type in the class name of the form part sample you are using (for example AbtNotesDemoForm45). For part type select View wrapper. Add the part to the free form surface and connect the selectedRow event of the iterator part with the openWidget action of the view wrapper. Also connect the selectedRow attribute with the promoted feature (named FormPartEditRow:) of the form part sample.
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