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

This is the promised followup to "Reordering items in a list," where I presented a LotusScript class named ListReorderDialog that takes a list of items and displays them to the user, lets the user change their order, and returns the reordered list.
To recap, the
ListReorderDialog class has the following methods and properties:

  • choices (Variant, input and output): the array of choices that is to be reordered.
  • defaultSelected (Variant, input): the list of entries that are initially selected in the dialog, to be used in cases where one or more entries is new and should be initially highlighted.
  • windowTitle (String, input): the title of the dialog.
  • promptText (String, input): text to be displayed at the top of the dialog.
  • Sub New(choices As Variant): The constructor can accept the list of choices as input, or you can specify "" here and set the choices later.
  • Function Ask( ) As Boolean: Display the dialog. If the user click OK, Ask returns True and the choices property is updated.
As I consider how to extend this class to the task of changing the sort order of documents, I'm not going to concern myself with how the methods are implemented. The theory behind object-oriented design is that the details are hidden for a good reason; if it matters how they are implemented, then the design has failed. Instead, we're just going to build on what we've already got by creating a new class, ViewReorderDialog. This takes a NotesView as input, scans its documents to make a list of document titles in order as they appear in the view. It displays the dialog to let the user reorder them, and then updates the documents to contain new values in the sorting field that will put them into the order the user selected.

The new class starts with the line:

Class ViewReorderDialog As ListReorderDialog

It inherits all the properties and methods of the ListReorderDialog class, except for the constructor (Sub New), which takes different arguments, and it adds some properties and methods:

  • Sub New(view As NotesView, descrColumnID As Variant, Byval strSortField As String): The view argument controls the sorting, descrColumnID is the column number (zero-based) or item name of a field containing the "title" of the document to be displayed to the user, and strSortField is the name of the number field that needs to be assigned to control the sort order of the documents. The method analyzes the design of the view to make sure it actually is sorted by the strSortField and if so, whether ascending or descending.
  • interval (Double, read-write): How much space to leave between sort numbers of documents (default = 10)
  • starting (Double, read-write): Where to start numbering (default = 10)
  • descending (Boolean, read-write): If True, assign numbers in descending order (assigned automatically based on the view you select, but you can override)
  • Key (Variant, read-only): If the view is not sorted first by the number field, this is the key value to filter to the set of documents you want to sort. For example, in this blog database, links are organized first by category, and the sort numbers are applied to order links within the category. So, it only makes sense to sort link documents within a single category -- not all the link documents at once. In this case, the key would be the category name.
  • Sub SetKey(newKey As Variant): This is how to set the Key value -- it retrieves the associated set of documents from the view and figures out their titles and sort order. If the number column is the first sorted column, pass the argument "".
  • Sub Commit( ): Reads the values from the Choices property, and sets the sorting field in the documents so that the documents sort that way in the view. The first document's sort field is set to starting, and they increase in steps of increment. If descending is true, the last document is set to starting, the second-to-last to starting+increment, etc.
  • Function SetDefaultDoc(Byval strDefaultID$) As Boolean: Select one document which will be selected initially in the resequencing dialog. We're assuming, for instance, that they will usually want to move the caret document relative to the other documents, so it's convenient if that document is highlighted. The argument is a note ID -- if there's no document with that note ID in the list, no document will be initially selected.
  • Function Reorder(keyVal, Byval strDefaultID$) As Boolean: Uses the methods SetKey, SetDefaultDoc, Ask (which is inherited) and Commit to prompt the user to reorder the documents, then if they clicked OK, saves changes.
Attached is a LotusScript file you can import into an agent; it contains both classes and some sample code to invoke the ViewReorderDialog in the DominoBlog template, for sorting "Link" documents. For the dialog form, see the previous entry, "Reordering items in a list." There's not room here to get into the details of what and why; I might have to write an article for dW.

Here's the script: reorder.lss

Andre Guirard | 26 April 2007 01:01:00 AM ET | Plymouth, MN, USA | Comments (4)


1) Error when clicking on the Reordering items in a list link
Betsy Thiede - Notes Geek Groupie | 4/26/2007 7:13:11 AM

Hi Andre,

When I click on the link, I get an errror: Invalid directory name or device not ready.

Andre notes: it should be fixed now.

2) URL is a notes.lnk
Kurt Higley | 4/26/2007 10:30:24 AM

Try this link => { Link }

3) Invalid directory name or device not ready.
kuldeep | 6/20/2007 11:59:31 AM

error in loyous


4) re: Invalid directory name or device not ready.
Andre Guirard | 6/21/2007 4:32:06 PM

Can you elaborate?

 Add a Comment
Comment:  (No HTML - Links will be converted if prefixed http://)
Remember Me?     Cancel

Search this blog 


    About IBM Privacy Contact