Mapping Document Collections To Views

It's now a couple of months since I wrote about a Super Useful Set of LotusScript Wrapper Classes, which I've written about on and off since February.

Today I want to share a few more extensions I've made to them, which help massively when it comes to getting documents from views.

Imagine the following use scenario:


Dim factory As New CustomerFactory()
Dim coll As CustomerCollection

'Let's get a collection from a view
Set coll = factory.GetAll()

'Or you could to this
Set coll = factory.GetAllByID()

'Or you could to this

coll = factory.GetAllByCountry() 'Or you could to this Set coll = factory.GetCustomersMatching("foo")


This code utilises the following functions in the CustomerFactory class:


Class CustomerFactory As DocumentFactory

  Private Function FromView(ViewName As String) As CustomerCollection
    Set FromView = New CustomerCollection(GetViewNavigator(ViewName))
  End Function

  Function GetAll() As CustomerCollection
    Set GetAll = FromView("AllCustomers")
  End Function
  Function GetAllByCity() As CustomerCollection
    Set GetAllBySite = FromView("CustomersByCity")
  End Function

  Function GetAllByCountry() As CustomerCollection
    Set GetAllBySite = FromView("CustomersByCountry")
  End Function
  Function GetAllByStatus() As CustomerCollection
    Set GetAllByStatus = FromView("CustomersByStatus")
  End Function

  Function GetCustomerByID( id As String ) As Customer
    Set GetCustomerByID = New Customer( GetDocumentByKey( "CustomersByID", id ) )
  End Function
  Function GetCustomersMatching(query As String) As CustomerCollection
    Set GetCustomersMatching= New CustomerCollection(GetViewEntriesByKey("(LU-CustomersByAllKeys)", query, False))
  End Function
End Class


In turn the above code relies on a few additions to the base DocumentFactory class:


Class DocumentFactory
  Function GetViewEntriesByKey(ViewName As String, SearchTerm As Variant, ExactMatch As Boolean) As NotesViewEntryCollection
    Set GetViewEntriesByKey = GetView(ViewName).Getallentriesbykey(SearchTerm, Exactmatch)
  End Function

  Function GetViewNavigator(ViewName As String) As NotesViewNavigator
    Set GetViewNavigator = GetView(ViewName).Createviewnav()
  End Function

  Function GetAllViewEntries(ViewName As String) As NotesViewEntryCollection
    Set GetViewNavigator = GetView(ViewName).AllEntries
  End Function
  Function GetDocumentByKey(ViewName As String, Lookup As Variant) As NotesDocument
    Set GetDocumentByKey = GetView(ViewName).Getdocumentbykey( Lookup, True )
  End Function
End Class


What all this does is make it a lot less tiresome to get a handle on document(s) relating to a particular business object (in this case documents based on the "Customer" form). The base DocumentCollection class now has helper functions to get all view entries or simply a view navigator object. It also has a GetDocumentByKey method which defaults the ExactMatch option to True, because it always is, thus saving us passing it in to the call.

Going Forward

I've also been using these classes extensively in a new Domino database I've been lucky enough to create from scratch and have been working on lately. As I've gone along I've been tweaking and extending the classes and now feel they're at a solid point ready for wider use.

I don't want to bang my own drum too much, but they're amazing. You maybe have to use them to see why, but, once you do, there's no going back. If this were ten years ago they'd be almost revolutionary.

Talking of going back; will I ever!? Will I ever be asked to create a new Domino-based web app from scratch? Never say never and all that, but I have a feeling I won't. Which makes it a shame that I developed such a rich and powerful way of working with Notes objects via LotusScript so late in my days with Notes.

Either way, if you're still working with and creating new Notes apps I implore you to give these classes a go. You'll love them.

My plan is to scrub them all a bit, document them better and then share on Github, along with a demo database. Assuming there's interest?

Comment Icon There are 14 comments in 7 threads Read - Add

Making Google Apps For Business Behave Like a Mail Client

So, I mentioned that I've moved to a new PC and, for the first time in years, I didn't install a dedicated Mail client/app. Instead I'm using direct web access to Google Apps For Business (posh name for paid-for Gmail).

The one thing I never liked about using Email in a browser is that I constantly close and re-open the browser. Thus, in effect, closing my email client, which I then have to remember to re-open.

Now though I've made it seem like a real app. You can do this using Chrome's "application shortcuts". Here's how.

First I setup a CNAME record in my DNS so that mail.mydomain.com points to Gmail. Then I visited the new URL in Chrome and, from the Options menu I chose Tools -> "Create application shortcuts...." which brings up this option dialog:


When I clicked Create it added a shortcut to my Taskbar, as below.


As you can see it looks just like a real application. It even tells me how many unreads there are.

The app runs in a chrome-less version of Chrome, as below:


I can now open and close my actual Chrome browser as many times as I like and my "mail client" stays open.

Did you notice the custom logo being used? Here's how.

You can also configure notifications to make it even more like a true mail client experience, where new email alerts appear on the bottom right of your screen.


All in all it makes for a nice experience. Now if only I could shake the un-nerving sense that I could lose all my mail at any point...

Comment Icon There are 6 comments in 5 threads Read - Add

Documenting Your LotusScript Classes

Just a quick LotusScript tip:

Hopefully you've been inspired by my recent adventures in creating custom LotusScript classes. If so, you'll have noticed that, when creating your own properties and methods in these classes that they get their own comments added in.

For example, if you type "property get foo as string" and then press return, you'll see something like this:

        Property Get Foo
        Description: Comments for Property Get
Property Get Foo As String

End Property

Domino Design auto-adds the comments above the property for you.

It's easy to see this as an annoyance and find yourself taking the comments out to keep your code tidy. However, I've forced myself to stop doing that and now make a point of adding in a meaningful comment. Like so:

%REM Property Get Action Description: Value of the "Action" field, which is used by the workflow associated with most documents Value is only available when editing/saving (not stored on document)! %END REM Property Get Action As String Action = GetFieldValue("Action") End Property

The benefit of doing so is manifold. Not only does it remind yourself what your intentions were but also, more importantly, future maintainers of the code.

But the real tip here is that, if you comment code using the standard way then, when you hover the mouse over a call to that property in use in your code you get to see the "documentation" inline. As below:


That alone makes it worth the time to document properly. Even if just for your own benefit as a quick reminder of what everything is.

Comment Icon There are 7 comments in 4 threads Read - Add

The Perfect Desk Quest - 2013 Update

It must be time for another update on how my desk is evolving towards the elusive "perfect desk". Previous updates here.

Here's my desk now, following a recent overhaul:


The two main differences from before: The Lenovo T400 laptop and its docking station have gone and the left-most monitor has moved positions to be on the right.

My desk needs to not only keep up with the way I work, but also the changes of the times. I decided it was time I got "with the times" and "embrace the cloud" and all that stuff.

For years my main work PC has been a laptop. For the obvious reasons, such as being able to work anywhere, being able to hide it when I go on holiday etc. It used to be that I'd undock the T400 each night and take it indoors of a night time. Then I bought the Yoga 13, which fast became my "house laptop" and the T400 was confined to the office.  The T400 was getting on for being 3 years old and had the noisiest damned fan in its docking station! It's days were numbered!!

While using a laptop as my main PC I have always missed having a dual monitor setup, which laptops can't deal with. Not easily anyway.

So, I've bought a Lenovo E31 SFF and stuck 32GB of RAM in it. This is now my main work PC and drives the two monitors to the right. I've missed having dual monitors!

Using the recently-discovered Hyper-V Manager tool for Windows 7 means I don't need the monitor attached directly to server. As you can see above the second monitor is showing a Domino server running in a VM on the server. It makes day-to-day Domino development so much easier having ready access to the server console.

No Email Client

The cloud now means I'm not tied to a single machine. When I do go "on the road" I can easily take everything with me.

For the first time in as long as I can remember using a PC with email I'm not going to install a Mail app. I've used various email clients over the years: Opera, Outlook Express, Lotus Notes, Thunderbird, Postbox, Mail.app. Now I'm just going to use Gmail.com online. Got to admit I don't like the idea that all messages aren't backed up on my own PCs. But hey. Brave new world and all that.

The only non-cloud-stored data I work with are Notes database. I tried using Dropbox to store my Notes Data folder, but, unsurprisingly, it didn't work. It probably could work if you made sure to only have Notes running on one PC at a time.

Moving from one PC to another this time was a lot less painful than it has been in the past. Still took a couple of hours. Not the full day of time it used to though.

Who knows what the 2014 update will bring. I just hope I'm still lucky enough to be working from my own little home-office, so that it matters either way.

Comment Icon There are 11 comments in 5 threads Read - Add

Updating Glyphicons in Bootstrap

Using Bootstrap, whenever I want to an icon to an element, I simply write HTML like this:

<a class="btn" href="foo"><i class="icon icon-plus"></i> Add New</a>

And I get something like this:


The choice of icons is documented here and the icons themselves are based on Glyphicons "halflings".

All is good.

However, recently I found myself wanting to use an icon to show that a document had some attachments. Naturally, I wanted a paperclip. Just like a magnifying glass denotes searching, a paperclip denotes a file attachment. Who knows why!

To my surprise the available set of icons listed on the Bootstrap site didn't include a paperclip. Really? But on further investigation it became apparent that the current version of Glyphicons did include a paperclip!

Here are the icons currently supplied with Bootstrap. It's a single flat image, which is used as a CSS Sprite:


And here's the image which represents the current release of Glypicons:




Notice the difference?

There are a few very slight differences. But the main difference is that the latter image has an extra row of icons. Not only that but one of them is a paperclip! Get in!!

Luckily (for me) the makers of Glypicons add new icons to the end of the grid, without changing the positions of the existing icons. This meant I could simply replace the image currently used by my copy of Bootstrap with the latest Glyphicons release. Without breaking the existing CSS/icons!

Once the new image was in place all I had to do was work out the grid size used, which, it turns out is 24 by 24 pixels. Before long I'd extended the available Bootstraps icons by adding the following CSS:

.icon-attachment {
  background-position: -24px -168px;

Job done. I love Bootstrap!

Comment Icon There are 7 comments in 2 threads Read - Add

‹ Previous | « Firsticon Page 4 of 344Last » | Next ›