New WebSession Agent Class

After no time at all I found myself writing new web-based agents without all that DocumentContext stuff in it. It's now as simple as this:

Sub Initialise
 Dim web As New WebSession()

 Print web.database.title

 Dim view as NotesView 
 Set view = web.database.GetView("RSS")
 Print view.name

 Print web.document.isnewnote

 Print web.user.common
 web.setUser web.document.curruser(0)
 Print web.user.abbreviated

 Print web.URLQueryString("test")
End Sub

As expected the output from the URL "test?OpenAgent&test=testes" was "HTMLArea Fields RSS True Fisher Anonymous testes"

Writing web agents from now on is going to be so much easier and I've already started using this new approach on actual projects I'm working on.

The only downside is that there's no autocomplete when writing code. Writing web.document and then another . doesn't bring up the list of methods and properties to choose from. I can live with that though.

I know what you're thinking. Where's that bloody download you promised? Well, it's close. Give me until Friday and I'll post something then. I just want to make sure it's suitable for use.


    • avatar
    • jay
    • Wed 15 Aug 2007 07:03 AM

    Very cool. I have always thought of doing something like this but never got to actually do it. Repeating those common "dims" was really annoying. Looking forward to your class :-)

    • avatar
    • tom
    • Wed 15 Aug 2007 08:29 AM

    R8 will have autocomplete for user created classes... no?

    • avatar
    • Jake Howlett
    • Wed 15 Aug 2007 08:49 AM

    The beta of 8 I just tested in didn't Tom, but hopefully the gold one will. I'll only have to live with this for the next two years then ;o)


    • avatar
    • Scott
    • Wed 15 Aug 2007 09:49 AM

    I'm not sure that the Gold one will either - I don't think designer got that much attention. 8.5 with Designer on Eclipse will (at least everyone asked Bob Balaban for it) so IBM certainly knows about it :-) And I would have thought the Eclipse framework will achieve this easily.

    As regards the class .. it might be worth using a Singleton design since per agent you should only have instance of this. Looks a Julian Rs NotesSystem class for an example of this.

    That way it the code would simply become:

    WebSession.URLQueryString( "test")

    And it would become globablly available within your agent. The downside being I think you have to Dim the global variable as a variant ! - so you'll probably never get intelli-sense :-(

  1. Hey Jake,

    Nice job getting to a useful place with classes so quickly. That's a good pattern there - putting all the system initialization in your class separates your host control logic from your display code, which as you no doubt see makes future revisions much easier to contemplate. Text book usage in my mind (for classes). There's a lot of things you can begin to leverage now that you are classy. :-)


  2. Actually experienced Java developers create utility classes for regularly used common .....

    • avatar
    • Bob M
    • Wed 15 Aug 2007 11:57 AM


    This looks good and I create HTML in my WQOs also but we are repeating history here. When Java first came out you coded your HTML in servlets. People quickly found that to be a nightmare to maintain. Then the Java community went to JSPs to separate design from business logic. Now there are more Java frameworks to create HTML than you can count. A domino framework needs to be developed that allows the separation between design and business logic. I’m suggesting Lotus do this not you-;)

    Your approach works great for an individual or small team but not for large teams. Please don’t take this post the wrong way. What you are doing is great thanks for all your hard work.

    • avatar
    • Axel
    • Wed 15 Aug 2007 01:09 PM

    I love this usage of classes for a specific technical task.

    I am getting impression that still a lot of people think, when they see class keyword, that now starts big Domain Driven Design and stuff. And as a result of overambitious plans so many classes I see in Lotus Notes projects are a bit bloated.

    OO features of Lotus Script can be used at much more mudane and pragmatic level. They can be happily mixed with good ole' scripts, etc.

    This definitedly looks like an implementation of usefull LotusScript OO not to be missed.

    OO can often be much more usefull when simply viewed as a language feature and not as an "architectural style". In the end the OO design is allways heavily dependant on the implementing language anyway (LotusScript, Java, JavaScript, Ruby, etc.).

    In the end an object of a self_created class is not much more than a set of functions packed together with some common global variables.

  3. @ Bob M

    That's a great point. In the past I created a class to serve as a tag parser that could pull documents apart and evaluate script or LS fragments ala JSP's in LS. What Jake has here is just what Axel says - good tool for the specific job in mind.

    What we are talking about is two different patterns. HTML that is meant to be maintainable as a requirement of the project necessarily should have a framework behind it so that frequent expected changes can be accommodated.

    Jake's example of the calendar from the other day is actually a component build, where having small reusable modules like this baked in makes the code more portable and tamper proof. No config files / documents needed. Using a framework would make the packaged drop-in module less packaged and drop-in.

    As someone I know says - horses for courses... :-)

    • avatar
    • Bob M
    • Wed 15 Aug 2007 02:05 PM

    I don’t see an alternative to Jake’s work in Domino except XML to XLST conversion. But I just wanted to point that it would be nice to see Lotus step up and provide such a framework so we are not stuck where Java was 7 years ago coding our HTML in WQOs.

    Has anybody else know of a solution in Domino to separate presentation from business logic?

  4. @Bob M,

    Here is a bit more detail on how I implemented Jerrys example, so that I didn't need to code HTML into WQO Agents

    I combined XHTML and the built in SAX parser with my own application tags code. I used a WQO and set of classes to translates my tags into xhtml and spit the whole lot out as a completed page. In the example below I used cde to distinguish the tag I wanted to translate.

    <p class="greetings">Welcome, <cde:username /></p>

    In the WQO the code is pretty much this, but with the error and logging parts omitted.

    Dim scmParser As New RenderFactory(session)

    Call scmParser.initialise(xml_in, xml_out)




    not only have you written a class, but you have also used the Facade design pattern - and there are more that apply to LotusScript.

    • avatar
    • Axel
    • Thu 16 Aug 2007 02:55 AM

    The free teamstudio ScriptBrowser adds some usefull tooling support for classes in LotusScript.

    No autocompletion when accessing a user defined class, but at least the thing gives you an overview about the member variables and methods of a class.

    Last time I looked into Domiclipse the developer started to parse LotusScript code with ANTLR, which could serve as a basis for create better tooling without waiting for Lotus to implement it in some future release. Currently I don't know how things has developed in that project.

  5. WRE Team Studio Script Browser:


  6. I have to say, a lot if interesting discussion the last few days. :)

    However, I do feel that since domino is so tightly woven with it's datamodel and design, it is very hard to really design a framework that effectively separates logic into for example an MVC pattern. One way of doing this would be to use XML and XSLT as someone mentioned, or special tag libraries. But then you loose much of what makes Domino usable as a web platform in the first place, the tight integration, and you might as well choose something better suited, like Rails, or Spring/Hibernate.

    What makes more sense to me is to look at forms as a display technology, and wqo agents as where application logic goes. This does work to a certain extent, and does give a reasonable separation, but of course I do wish that IBM would do some things to make it better. Making formulas evaluate after wqo would be one thing, but also being able to make formulas access script libraries (or even custom formula functions) would enable reusable tag libraries.


    Bjorn Cintra

  7. Yes Bjornm, you are right.

    Unfortunately, the MVC "à la Notes" is a myth, Notes already offers heavy component,

    A way is to create "layered application" to reuse code.

    In this case the agents are a technical layer in the middle. It gives us Notes or web context, business logic selector, late bindings mecanism (a controller/Factory )ect. The class & forms are on both ends with business logic and presentation/input validation. A domino's framework would be rather a whole(?) of best pratices/systematics ( centralize validation & hide-when rules for both Notes & web(server side validation), deport code to LSS) and Domino's funky geek's technics (doClick, formula return code). This with the goal of embrasse change, keep simple (at least be systematics !:-))

    LS OO implementation is poor. But encapsulation give us great tools to simplify the code (less parameters between calls...)... please avoid globals variable (aaargh!!).

    I commonly use a "singleton" object (ok ok it's a global...) to cache instance of heavy object (view, ext db) -> only 1 new NotesView(), DB ect.

    It's also cool for collection processing : Create a bean class for your document, walk on each document one time to instanciate beans & finally do what you need on those instance.

    In this context, the list are real powerfull tools to hold instance in a "hashmap" structure... There are a lot of techical or functionnal wrapper class to write (mails,RT, queryString parser, (notes)date/time helper).

    With tools like lsdoc, TSscript browser or NotesHound you have alternative to poor Designer IDE integration.. garggl

    Class will really help you :-)

  8. Designer 8.0 won't have autocomplete for your own classes. Designer as an Eclipse plug-in will have that. If things go well you will see it in the 8.x timeframe.

    You can head over and sign the petition: {Link}

    :-) stw

  9. I implemented this with revisions this month. I added methods to get query string, cookie and form data.


    This is just so much cleaner and easier than having a bunch of functions.

Your Comments


About This Page

Written by Jake Howlett on Wed 15 Aug 2007

Share This Page

# ( ) '


The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social

About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content