IBM®
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

There's a known issue with the use of "single category" views and @SetViewInfo to display a single category, that if the user does a collapse all (Shift + -), all the documents in their selected category vanish from view, like presents before a grinch. This is SPR DPOL6MMK6W, documented in technote 1235978 (pending publication).

There's no fix for this as yet, but I've been thinking about it and came up with a workaround for cases where there's only one level of categorization. The view also needs to either be used only in single-category mode, or else you have to do a little extra programming to communicate to the view code whether it's in that mode, e.g. set an environment variable.

For version 7 and previous, use a NotesTimer to poll the CaretNoteID and notice when the selection changes to a category row; when that occurs, we know the view has been collapsed, and take action to uncollapse it. I call this the "No You Don't" technique. With version 8, the new Onselect view event makes things simpler; you don't have to poll because you get notified every time the caret changes.

Here's the code for 7.x:

(Globals)
Option Declare ' always use Option Declare

Dim atimer As NotesTimer

Dim thisvu As NotesUIView

Dim thisdocID As String


Sub timerEvent(Source As NotesTimer)

Dim newID$

newID = thisvu.CaretNoteID

If newID Like "[89A-F]???????" And Not (thisdocID Like "[89A-F]???????" or thisdocID = "0") Then

 ' The user has collapsed the view. Uncollapse it by moving the caret to the previously selected document.

 Source.Enabled = False ' navigating a view can take time; make sure there's no pileup of timer events.

 Dim doc As NotesDocument

 Dim db As NotesDatabase

 Set db = thisvu.View.Parent

 On Error Resume Next

 Set doc = db.GetDocumentByID(thisdocid)

 thisvu.SelectDocument doc

 Source.Enabled = True

Else

 thisdocid = newID

End If

End Sub


Sub Postopen(Source As Notesuiview)

Dim session As New NotesSession

Set thisvu = Source

thisdocid = Source.CaretNoteID

Set atimer = New NotesTimer(0.5)

On Event alarm From atimer Call TimerEvent

atimer.Enabled = True

End Sub

raccoon.gifA few points to consider:
  • A determined end-user can still manage to make trouble, for instance by deleting a document and then immediately collapsing categories before the timer event can trigger again. End-users are like raccoons; if there's a way they can cause a problem, they generally do. So if you have to be 100% sure this doesn't occur, either use 8.0 (where you can put the code in the Onselect event so that the speed of the user is not a problem), or add code that knows what category it's supposed to be displaying (by an environment variable perhaps), and in case of failure to find document "thisdocid", searches the view to find the first document in that category instead. You can elaborate on this in other ways; I just wanted to present the basic technique.
  • If you do have multiple categorized columns I don't have an answer except you could use "categorized is flat" on the 2nd and subsequent category columns. Maybe you could play around with it and find a way to distinguish between first and second-level category entries, but it's likely to be slow.
  • A "view refresh" will also correct the display. However, NotesUIWorkspace.ViewRefresh doesn't work unless the focus is in the embedded view, so once again if the user is quick they can collapse all and then exit the view before you have a chance to fix it. If you can use Onselect, you can assume the view still has focus.
I know this is a bit of a kludge; anyone have a better workaround, or care to take the time to refine this solution so that it works more reliably?

Incidentally, if this problem irritates you, please call support and complain about it. The more people complain, the more likely it is to get fixed.

UPDATE: here's the code for 8.0 and beyond. The ViewRefresh method doesn't work in this context to reopen the category -- not sure why.

Sub Onselect(Source As Notesuiview)
  Dim newID$, cat$

  newID = Source.CaretNoteID

  If newID <> thisdocid Then

     If newID Like "[89A-F]???????" Then

        ' user selected a category entry -- we're assuming this means they collapsed all.

        Dim db As NotesDatabase

        Dim doc As NotesDocument

        Set db = Source.View.Parent

        On Error Goto tryAnotherWay

        Set doc = db.GetDocumentByID(thisdocid)

        Source.SelectDocument doc

     End If

  End If

resumePoint:

  thisdocID = Source.CaretNoteID

  Exit Sub

tryAnotherWay:

  Dim vu As NotesView

  Set vu = Source.View

  On Error Resume Next

  Set doc = vu.GetDocumentByKey(Source.CaretCategory)

  Source.SelectDocument doc

  Goto resumePoint

End Sub

Andre Guirard | 6 December 2007 10:40:00 AM ET | Plymouth, MN, USA | Comments (2)

Search this blog 

Disclaimer 

    About IBM Privacy Contact