I'm working on converting an IIS/Flash website to Domino at the moment. The new Domino site has to work as near to exactly the same as the .asp site as possible. I'm determined to eradicate all the Domino nuances. This morning I excised it of an age-old view navigation gotcha, using some simple LotusScript.
Have a look at the gallery on the current site. Click on an artist to launch the popup with a photo in it. Notice this popup has previous and next links. Easy to do in Domino with a simple @Command([NavigateNext]) Action Hotspot. The trouble is that Domino throws you back in to the view when you press next and happen to be in the last document. I needed to replicate the way that the previous link didn't appear in the first document and, similarly, neither did the next link in the last.
To do this I created a field on the popup document call "Position". Its value will be set to either "First" or "Last" by a WebQueryOpen agent. Using Hide When Formulas it's easy to hide the links when they don't apply.
The code for the agent is quite simple (I've missed out the Dim statement for the sake of brevity):
Set doc = session.DocumentContext
Set view = db.GetView("gallery")
Set nav = view.CreateViewNav()
Set ThisEntry = nav.GetEntry( doc )
Set FirstEntry = nav.GetFirstDocument
Set LastEntry = nav.GetLastDocument
If ThisEntry.UniversalID=FirstEntry.UniversalID Then
Call doc.ReplaceItemValue( "Position", "First")
If ThisEntry.UniversalID=LastEntry.UniversalID Then
Call doc.ReplaceItemValue( "Position", "Last")
It uses the NotesViewNavigator class that was new back with R5. Don't know why I've not thought of doing this before. Have I re-invented someone else's wheel?
Using the Count property you can also hide previous/next links at the view level and even add some "Page X of Y" text using a WebQueryOpen agent in the $$ViewTemplate.
Does that make sense? Is it too obvious/simple for me to bother making an article of it with a demo DB?
Note: Since I wrote this I found a small logic problem with the code. Can anybody spot it?