Thursday, December 20, 2007

SnTT : Unit Testing In Domino

I've had this database of code that is a framework for Unit testing in Domino/LotusScript. Its somewhat similar to JUnit. I wrote it so that I could double check code that was high risk and to give me another level of confidence that it would cope with the unexpected. I've been meaning to add a little polish to the database before I release it into the community. I've finally got around to it this week (and just in time for SnTT). It's not 100% complete, but might be of use to someone and rather than it sitting on my disk I've published it as a project on OpenNTF (here).

Follow this link to find out what is JUnit?

JUnit fits into a technique for Test Driven Development (TDD) where the basic premise is that you write tests for a unit (function, method etc) before writing the actual code. You then write your intended function (or method etc) until it passes all of your pre-written tests. In practice this is quite a large shift in mindset for some programmers. However, writing unit tests without adopting the whole TDD can still be beneficial (and I believe is quite common). For me it means that I can have a set of tests that I can check against code quickly, in a repeatable way and if I need to refactor my code I can quickly determine the impact of those changes by the success (or failures) of the existing tests.

The 'Domino Unit Framework' (DUF) is the Domino (or maybe that should be LotusScript - although LUF isn't quite as funny) take on this framework. The database contains example code in the one and only agent, but here are a few snippets so that you can see how it works.

Dim OutputStream As NotesDatabaseOutputStream
Set OutputStream = New NotesDatabaseOutputStream(session, "", "DominoUnitResults.nsf")

Dim testObject As New Test("Test Objects", Outputstream)
Call testObject.AssertEqual(session.currentdatabase,Null)

You can also check for True or False, in the example below I have just passed a True/False but typically you would include your code that returns a true or false.

Call testTrue.AssertTrue(True)
Call testFalse.AssertFalse(False)
Call test.AssertFalse(object.myMethodThyatIExcepectToReturnFalse)

You can also group up a set of tests into a 'suite of tests' which you can get an overall pass or fail or maybe just group them into logical functions.

Dim testSuite As New TestSuite("isMemberTests", OutputStream)
Call testSuite.Add(test1)
Call test1.AssertEqual(True,isMember(vArray2,vArray1))

So what objects does this support ?

Currently the following objects are supported as they were the ones that I needed - I might added more later or maybe someone else might like to (if you fancy contributing).

- integer
- long
- double
- currency
LS Date
Boolean (Integer)
- NotesDocument (based on UNID)
- NotesDatabase (based on Replica Id)

Can I test my Own classes ?

You can also unit test your own custom classes. You will need to implement an isEqual method which the framework expects.

Dim tony As New Person
Dim emp As New Person

Call tony.init("Tony","A","Palmer")
Call emp.init("Tony","A","Palmer")

Call Test101.AssertEqual(tony,emp)

Class Person
Function isEqual(people As Person) As Integer
' add in your own code that determines equality or not.
End Function
End Class

How can I have a quick look ?

Just download the DUF Database from OpenNTF and then create a copy (without Documents) in the root directory with a name of DUFResults.nsf. Then in the DUF database run the 'Development / Unit Test Agent'. There are some screen shots here of the database here.

Until Next Year.

I expect that this will be my last SnTT post until after LS08, I'm not going but will spending my time following all the news remotely.

Merry Xmas (Happy Holidays!) and Happy New Year.

Thursday, November 22, 2007

IBM Education Assistant - Building Composite Applications

from the Notes 8 forum,

For those building Composite Applications here is the latest version of the multi-media tutorial on building Notes 8 Composite Applications using IBM Education Assistant. It provides a great overview of Composite Applications, as well as, detailed step-by-step instructions on how to build one:


Wednesday, November 21, 2007

SnTT : The Simplest Property Broker Example in Notes 8


I've created a very simple, if not the simplest, property broker example using the Expeditor Toolkit. The idea is to understand the property broker and wires as part of the new breed of applications that integrate eclipse plugins and ND8.

In keeping with the 'simple' theme, I wanted a simple database...err...application that would have a simple notes view, when I select a document in the notes view the content in the column is sent to the text box on the TargetView view part.

Blank Composite Application

I created a new composite application (CA) from the " - blank composite application - " template, which promptly opened to show me the message

"This application page does not contain any content".

I opened the application with Designer and added a view and a form - nice and simple. Next I wanted to add a few documents. I needed to edit the composite application and add the notes form and view. Then from the action > edit application you can access the composite application editor and under the right hand side flyout pane (components palette) is the form and view.

I dragged the view into the blank page and closed the CA Editor, it now looks like an old school Notes database. I could then add in a few data documents ready for the next steps.

Packaging the Plugin

What you need to do is package up the plugin into a format that you can install into ND8. This is through the tried and tested
update-site-format. If you have applied patches or upgraded RAD/RSA you would be very familiar with this way of installing plugins and updates.

The instructions to update the plugin build properties, create a feature and generate an update site are in the tutorial "
CompAppsTutorialPart2M4.pdf". I followed these instructions and built the update site. So far so good.

Installing a plugin

Back to the Notes application and the CA Ed
itor. I need to add into the component palette my two ViewPart (TargetView and SourceView). To add components you right click, then choose Add Components > Add Components from Update Site.

My update site is in local directory, under my workspace directory. so I browsed to the site.xml and clicked OK. I was then given a dialog to select the components from the update site. Strangely the SourceView component was missing. No drama as it's the TargetView compone
nt that I needed anyway. I added the component and then dragged it onto the main page. Positioning can be a tad awkward. If you want to have the component on the bottom most part of the screen then you will need to drag the cursor right to the bottom of the screen.


In the left hand menu I selected the 'source' component the Default View (notes) component and right click then wiring - I could see the 'sets the target message' action in TargetView but there was nothing to wire from. I could see the 'Default View' component but no property.

oops...More wires

I had forgotten to add in the Notes side of the wiring. I created a new wiring properties (sample.wsdl), then opened the WSDL file with the editor and added a notesValue property, updated the namespace to cahelloworld.nsf and added a setter and getter action. The dialog is the same as the wiring editor in the Expeditor Toolkit.

It was still not working. Come to think - how would the view know which property change has happened ? In the column properties in the 'Programmatic Use' tab there is a new setting on the bottom just for this...

Composite Settings : Property

In the drop down there was only one choice 'notesValue'. When I went back to the Wiring Editor and the 'notesValue' property was showing. I wired them together and closed the CA Editor and the text box had a value. I selected the other documents and the text changed in the eclipse plugin.

I also found out why the SourceView wasn't listed when I came to add the component. In the plugin.xml the TargetView Extention element 'allowMultiple' wasn't set.

The eclipse
documentation specifies that...

allowMultiple - flag indicating whether this view allows multiple instances to be created using IWorkbenchPage.showView(String id, String secondaryId). The default is false.


On the whole the packaging up of the site and installation was fairly easy - until I moved the cahelloworld.nsf to another workstation. I'm not entirely sure about the deployment and distribution of a CA. One of the great thing about Notes applications is that deploying an application and new version is an easy process. Update the templates, maybe run agents to modify documents and thats it. Even if you have a Dev/UAT/SIT/Production type environment, it is still relatively simple. CA's will add another level of complexity to the equation.

I also found that the Help > Support > View Trace (and View Log) is helpful in tracking down property broker issues. Have a go at installing the BIRT sample in a directory other that the Notes data directory and then having a look at the Trace and Log. BTW the report does not generate, so don't hang around waiting. The logs show why.

So, there you have it. Quite possibly the most simple eclipse plugin and notes 8 composite application example.


Thursday, November 15, 2007

SnTT : Quite possibly the simplest property broker example

I've completed step two of my "Adventures in Expeditor Toolkit". It is quite possibly the simplest property broker example. One target view, one source view and one property.

I looked the the Color Swatch example that comes with the toolkit. It had multiple properties and three views and the naming convention for a beginner was a little convoluted.

I decided to create my own 'hello world' property broker example. I've attached a zip of the workspace it you want to run it or browse the files.

This purpose of this post is to share with you a very simple example to get to grips with the Property Broker and Wires. Something that the average
Lotus/Notes Developer can look at, run and understand.

About the Hello World Example

I wanted a component where I could enter some text and using the property broker, send this to another component for display.

I started with the New > Project > Client Services > Client Services Project followed the prompts including choosing the 'rich basic application' which generates some of the bits required for the project. I then looked at the Color Swatch sample and worked out which parts needed changing. If you need step by step instructions on how to create a composite application, wires and actions in Expeditor then you should look at the redpiece, redbook, and the tutorial posted in the nd8 forum .

So lets have a quick look at the parts of the puzzle. - this pulls the components/view parts into the application and is one of the first files run - the view part that contains, the field to enter the message and a button to trigger the location of a property, changing the value and sending the notification that a property had changed - the view part that sets the text box with the value of the change property - the action that is called by the property broker, and checks if the event is a property change event, and calls the TargetView to update the text box with the new value.
source.wsdl - contains getSourceMessage action and outgoing property MessageItemValue
target.wsdl - contains setTargetMessage action and incoming property MessageItemValue

I had all the parts of the puzzle there, but I couldn't get the Wiring Properties Editor to produce the same WSDL file as the Color Swatch example, so in the end I updated the file manually to set the actionNameParameter attribute and remove the boundTo="request-attribute" attribute. I also renamed the <portlet:param name/> to setMessageValue for target.wsdl and getMessageValue for source.wsdl

I could run up the application, but nothing happened. I added a few debug lines and I could see that the property was being set in java but what about the property broker.The post on the Composite App details how to trouble shoot with the OSGi console. You can enter these commands in the eclipse console at the osgi>

pbsh p - showed me the current properties

Owner = com.scius.examples.helloworld
There are 2 properties registered.
Name: setMessageValue
Type: string
Class: class
Default: null
Direction: [IN]
Is Wired: NO
Name: getMessageValue

Type: string
Class: class
Default: null
Direction: [OUT]
Is Wired: YES

pbsh a - shows me the actions
NAME: getSourceMessage

Handler Type: SWT_ACTION
Runnable Type: com.scius.examples.helloworld.actions.SourceAction
Owner ID: com.scius.examples.helloworld
Name Parameter: ACTION_NAME
Parameters: 1 parameters
Property = getMessageValue
Property NS =
Type: string
Property ClassName = java.lang.String
Property default Value = null
Direction: [OUT]

NAME: setTargetMessage
Handler Type: SWT_ACTION
Runnable Type: com.scius.examples.helloworld.actions.TargetHandler
Owner ID: com.scius.examples.helloworld
Name Parameter: ACTION_NAME
Parameters: 1 parameters
Property = setMessageValue
Property Title =
Property NS =
Type: string
Property ClassName = java.lang.String
Property default Value = null
Direction: [IN]

pbsh aw - shows me the active wires

Owner = com.scius.examples.helloworld
There are 1 wires registered.
Title: Source to Target Message
Id: PROPERTY_TO_ACTION_WIRE:getMessageValue:setTargetMessage:com.scius.examples.helloworld.richapp.SourceView:com.scius.examples.helloworld.richapp.TargetView
Owner Id: com.scius.examples.helloworld
Ordinal: 100

Source Name: getMessageValue
Source Entity ID: com.scius.examples.helloworld.richapp.SourceView
Source Param: null
Target Name: setTargetMessage
Target Entity ID: com.scius.examples.helloworld.richapp.TargetView
Target Param: null
Is Cross Page: false

In the documentation the description of how a wire docking point is described as such.

In order to wire a docking or end point the location is uniquely identified by the following

  • The property’s namespace
  • The property’s name
  • The property’s type
  • The component’s entity ID
When I looked through the information from the diagnostics it all looks good so why is the example not working ?

OSGi console allows you to trace properties, so I registered each property.

pbt setMessageValue

pbt getMessageValue

osgi> pblt
Registered Property Traces are:
1. setMessageValue

2. getMessageValue

I tried again and this time there was more information from the trace

osgi> com.scius.examples.helloworld.richapp.SourceView:Text to be sent:hello world
com.scius.examples.helloworld.richapp.SourceView$Listener:Sending Property Change Notification 2007/11/16 10:09:50.062 WARNING PBTRACE(getMessageValue) changedProperties was called. ::thread=main

So it looks like the notification is being sent correctly, but the isn't being called. Why ? This paragraph in the redpiece fills in the last piece of the puzzle.

However, as a view can be used in multiple places, sometimes
even on the same page, a secondary ID is required to uniquely identify a view. If you declared your application through a perspective as described in 3.9, “Laying out applications programmatically” on page 53, you might not have provided any secondary IDs for your views. You must, however, always do so. Property broker assumes, that all views have secondary IDs.

So even though I was only using one instance of I needed to uniquely identify the View. I'd seen the ":fore" and ":back" seconday ids for the Color Swatch but thought that I didn't need them - once I added the ":hello" secondary id to the id and all references the sample worked.

So there you have it - one working very simple property broker and wires example.

Tuesday, November 13, 2007

SnTT : Using DXL and Java to update view designs

In a recent project I needed to apply a new corporate interface design to a bunch of databases. Modifications to frames, pages, forms and views. The objective was to provide consistency for the end users. Updating the views was by far, the most time consuming and tedious part. I needed to find a quicker and easier way before I ended up with RSI.

Enter DXL, with a dash of Java. I decided that Java and Eclipse would a better choice
rather than Domino Designer and LotusScript. As a tool it would be independent of a notes database and there are plenty of dom and sax parsing libraries to choose from. I also chose to use eclipse so that I could ensure that the tool could be used and extended further by my client.

The objective of the tool was to export the DXL for all the views in a database, then add or modify particular elements to change the style, colours and which shared buttons appear for each view. The modified DXL would then be imported into the database to make the changes.

Below are snippets of the important pieces of the puzzle.

Here I export the views DXL into the DOM parser

DxlExporter exporter = s.createDxlExporter();
org.w3c.dom.Document doc = fac.newDocumentBuilder().parse( new InputSource(new StringReader(exporter.exportDxl(note))));

Then manipulating the actionBar node background colour, borders and style

actionBar.setAttribute("bgcolor", "#004573");
actionBar.setAttribute("bordercolor", "black");

actionBarStyle.setAttribute("height", "40px");
actionBarStyle.setAttribute("repeat", "resize");
Element imageRef;
imageRef = (Element) actionBarStyle.getElementsByTagName("imageref").item(0);
if (imageRef == null)
imageRef = doc.createElement("imageref"); actionBarStyle.appendChild(imageRef);
imageRef.setAttribute("name", "fade-blue-blue.gif");

And then import the modified XML DOM into the database

ByteArrayOutputStream bs = new ByteArrayOutputStream();
OutputFormat fmt = new OutputFormat(doc);
XMLSerializer writer = new XMLSerializer(bs, fmt);

Stream stream = s.createStream();
stream.setContents(new ByteArrayInputStream(bs.toByteArray()));
importer = s.createDxlImporter();
importer.importDxl(stream, dbTarget);


There were a few gotchas where the importer expects elements in certain order and a particular nasty bug in 7.0.2 that corrupts the view/column formulas. As far as reducing the monotony in updating a design I would highly recommend this approach and hopefully you can take the skeleton code and extend for you own purpose.

You can download the workspace zip file. You'll need to update the location to the NCSO.jar and Notes.jar libraries from my location of c:\lotus\notes.

WARNING : You must ensure that you are using Lotus Notes Designer 7.0.3 otherwise you will corrupt your views - see this technote and try it on a test database.
I haven't tried this in version 8.0 either.

Friday, November 09, 2007

Adventures in Expeditor Toolkit

I've been interested in the Composite Application features in Notes 8, in particular the ability to integrate rich client applications with notes. I've had some time recently to start looking in a little more detail. The interesting part is the way in which the PropertyBroker and Wires allows you to connect components together. I thought that I would have a go at creating a simple 'Hello World' example that I could integrate with a notes app.

I've seen the Demos of other composite apps, but there is nothing like rolling your sleeves up and getting into the code. The Expeditor 6.1.1 toolkit is available to use in either Eclipse or the Rational Application Developer and Software Architect IDE. I decided that I'd use the RSA I already had installed.

followed the instructions and Installed the toolkit - there were no surpises. I then installed the PropertyBroker sample application, ran the application and it popped up under the 'open' menu. It pretty much confirmed that environments were working together - all going according to plan.

The next step was to create my own 'hello world' component.

I chose New > Client Services > Client Services Project, filled in all the default values and chose Rich Basic Application from the list of templates.

This generated some java files, properties and the plugin.xml files. The UI comes named as, which you can either open with the Java editor or the Visual Editor. The Visual Editor gives you a graphical view of the Java code - similar to form designing in Domino Designer.

The next step was to add in a 'Hello' world label and then run it in Notes to comfirm that this new project can run in Notes 8

So what next ? I just wanted to see if I could add a break point and would that work with Notes, so I added a break point an ran the component using the Run > Debug menu (rather than the run option) - and yes the breakpoint worked - very cool.

Getting the wires and PropertyBroker working is the next challenge that I'm working through.....

Wednesday, November 07, 2007

SnTT: NotesSAX Parsing

Jake was asking about how to filter out malicous tags and code, I suggested using the NotesSAXParser after the HTML is converted to XHTML. I'm suprised that no one uses this as an approach, I mean fundementally XHTML is XML and the right tools for parsing this is the NotesSAXParser and NotesDOMParser. I figured that maybe there has not been a example of its use. So here is a sample class pulled right out of our home grown content management system - which uses NotesSAXParser - a little early for Show-and-Tell Thursdays...

Sunday, November 04, 2007 version 2.0

I've finished updating the company's website. The original design (below) was a bit incipid and dull, something that I managed to throw together in my spare time. We decided to spend a little more time and effort on the design and implementation for version 2.0 (on the bottom of the post).

The website runs on our home grown product - a web content management system written in Domino. This is primarily so that the non technical members of the team can update content easily without effecting the design and layout.

I wanted to target four of the most popular browsers, IE version 6 and 7, Firefox 2.0 and Safari 3. I've managed to achieve this, XHTML and CSS W3C validation by following some simple rules.


1. for height use both the HEIGHT and MIN-HEIGHT
2. for width use both WIDTH and MIN-WIDTH
3. for BORDERS, MARGIN always use the LEFT, RIGHT, TOP and BOTTOM qualifiers rather than the MARGIN:5px 10px 5px 10px even though its CSS 1 valid


XHTML Transitional

1. only have one occurance of id="identifier" for elements (if you need more than one then it's a class="" approach)
2. close all tags with either a forward slash of closing tag i.e. <img src="" alt="" /> or </img>
3 ensure that each IMG tag has an ALT attribute

4 keep all tags lowercase (even through I've used uppercase for clarity in this post...ok)
5 avoid nesting elements unless its in a div. i.e. don't nest a <h1> in a <p>

There you go, one css file and a simple design which displays the same for all of my target browsers and validates against XHTML and CSS.

Thursday, October 04, 2007

SNTT : The value of OO and reuse

I've just finished a project and had some spare time. The domino website that we have been running for a particular client needed some new content and a email mail-out send to all the website members to let them know. So I started having a look at how I should do that and in 30 minutes I'd finished.

The website already have functionality to send confirmation emails, but mail-out functionality was not included in the original scope.

So how did I manage that ? The architecture of the website is built using xml templates for web content. Early on in the development, I'd decided that email templates should also use XML. After all the the mime messages that we need to generate are pretty much XML and I could extend the XMLRenderFactory to also do the email template to mime rendering.

So I started by creating the new email mailout template like the confirmation emails. The example below has been change slightly. note the <scm:xxx> nodes.


<style type="text/css">
<table border="0" width="499px" cellspacing="0" cellpadding="0">
<tr><td bgcolor="#990033">
<img src="http://www.somewebsite/x.nsf/mailbanner.gif" width="500px" height="50px"/>
<tr><td bgcolor="#990033" color="white"><h1>New Resources are available online</h1></td></tr>
<p style="font-size:10px; color:#B10034;font-family:verdana">Dear
<scm:profile key="firstname"/> <scm:profile key="surname"/>
new resources are available on-line now.<br/><br/>
<tr><td bgcolor="#990033">
<p class="footer"><img src="http://www.somewebsite/x.nsf/footerlogo.jpg"/></p>

I looked at the shared action that was currently used to send an registration emails.

Set confirmMessage = New SCMTemplateMailMessage(session,note)
confirmMessage.SendTo =
Call confirmMessage.SendMessage("register_confirm")
note.registration_sent = Now
Call note.Save(True,False)

I created a new one, and change two lines and added it to the form.

Set confirmMessage = New SCMTemplateMailMessage(session,note)
confirmMessage.SendTo =
Call confirmMessage.SendMessage("mailout_series2")
note.mailout_2 = Now
Call note.Save(True,False)

I ran it against a profile of a test member. Then I needed the ability to send bulk mail-outs so I wrapped the whole thing into an agent to run against selected members in the database.


I couldn't have done this if the architecture of the application hadn't been using an Object Oriented approach, abstracting the email message into a SCMTemplateMailMessage provided flexibility in reusing it for something that was outside the scope of the original design.

If someone questions the value of using OO techniques in Domino or Lotus Notes send them here.

Monday, August 20, 2007

Extending Domino with Java - Part 4 - Integration

I was inspired by Stephen Wissels JMeter post to finally finishing up the Extending Domino with Java posts. If you want to skip to the finish line, then you can download the finished code examples in a Domino database from openntf code bin.

So you have the HTTPFacade class working nicely in eclipse - how do you get that running in Domino. We could create an agent and attach, the and supporting jar files - but if you created another agent to do the same and attach all of the file again. So I decided to create a reusable Java Library in Domino. If you have never done this before, don't worry
its just as simple as the LS libraries.

I created a library called HTTPLibrary and pasted the HTTPFacade java code from eclipse, of course this won't compile just now. In eclipse I referenced the apache commons HTTPClient and dependant jar files - we need to do the same in Domino.

Click 'Edit Project' and add/replace the jar files from your local disk into the java library. It should look something like;

That's great but lets get a simple example working in Domino. Start with a Java agent. Create a new one, which has all the stub code. How do we reference the shared library ? simple. Just click 'Edit Project' the in the 'Browse' dropdown, then choose 'Shared Java Libraries'. You should see 'HTTPLibrary' as an option. Add that library to the project.

You can then start using the HTTPFacade class in the agent (see the JavaLibraryExample agent in the sample database).

dhttp = new HTTPFacade("");
dhttp.setWebsiteCredentials("username", "password");
String url = "";
returnCode = dhttp.executeMethod(url);

When you save the agent you should get a 'Successful compile." message if the library contains the correct jar files and is referenced.

Now try and run the Agent. What happens ? nothing ? The output is sent to the standard system.out stream. In the Notes client you need to open that stream by choosing 'File > Tools > Show Java Debug Console'. This will open the Java console and you should see the HTML output from you agent.

That's good - but what if I want to use this outside the context of an agent, in a button and in LotusScript. You can invoke Java from LotusScript using LS2J. We'll use this for the final example of integrating into a form. What we would like is that when we click on a button, we'll display the return code in a dialog and then populate a field with the HTML.

In order to use LS2J you need to add the following line into the button's option script.
While you are there add the HTTPLibrary too. The options should look like

Uselsx "*javacon"
Use "HTTPLibrary"

You will need to create a JavaSession, JavaClass, JavaError and a JavaObject variables, plus a few others (there is example in the Designer help). The below code snippet show the examples and how to create a reference to a Java object, set properties and execute a method - all without leaving lotus script.

Set mySession = New JavaSession()
Set myClass = mySession.GetClass("")
Set dhttp = myClass.CreateObject()

Call dhttp.setHost("")

sXML = dhttp.getXML()
ret=Messagebox(Cstr(iReturn), 0,Cstr(iReturn))

Call uiws.CurrentDocument.FieldSetText("xml",sXML)
Call dhttp.releaseConnection()

That's it, a simple interface to an already existing 'robust HTTP class library' that you can easily reuse in LotusScript or Java in Domino. You can also use the, and java.util packages to create your own HTTPClient as in Julians urlFetcher database.....or maybe just use his database.

I guess what you can take away from this series of posts is that there is a large volume of work in the java world that as a Domino developer you can take advantage of. I hope that from the examples you can see that it's not that hard. With the new version of Notes 8 coming and the composite application model, there is only going to be more that is available to us to produce innovative client and web based applications.

Sunday, June 10, 2007

Extending Domino with Java - Part 3 - Facade

A few other priorities took over my free time, so part three has been a little long in constructing. The sample was a good starting point, but we need to provide a nice clean facade that will be easier to reuse.

I started by creating the HTTPFacade class as the intermediate layer between the HttpClient and the Domino Agent class. I could have extended tha HttpClient but that would mean that I would be reliant on the underling libraries. I decided against that.

The first thing that needs to happen is to extract all of the information that the HttpClient needs so that we can set those values through either the constructor or setters. I used member variables as part of the class to store things such as the url, usernames and passwords. This brings me to eclipse tip #1. One of the features of eclipse that I like is that if you create your member variables and then right click source > generate getters and setters eclispe will create all of the code.

Once I had the facade ready but without the authentication I ran it against a secure website. The following message came up in the exceptions. It give you some solid information as to how to start setting up the authentication options.

May 17, 2007 9:23:16 PM
org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthSchemeINFO:
basic authentication scheme selected

May 17, 2007 9:23:16 PM
org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallengeINFO: No
credentials available for BASIC 'By Invitation

A quick look at the documentation and a few refactors later I ended up with the following addition to the original code.

if (this.isWebsiteCredentialsUsed())
Credentials defaultcreds =
new UsernamePasswordCredentials(this.getWebsiteUser(),
client.getState().setCredentials(new AuthScope(this.getHost(),

I also added a few other methods to the standard executeMethod, such as executeMethodWithWebsiteCredentials and executeMethodWithWebsiteAndProxyCredentials. Yes I know long names, but at least you can tell what they do.

Next I had two choices. One, test this in Domino or Two, create a unit test class that I can unit test the facade. For simplicity sake I chose the java unit test, by creating a mockAgent object.

Here comes eclipse tip #2. Document your methods, getters and setters as you go, that way when you type ahead inspects your code you get a nice description to help you write the your code. For something this simple it's probably not that much of an issue, but if you have lots of custom code then it a great help. This is one of the feature that I so, so would like to see in Domino designer.

I've included attached the two java files. I've included the proxy authentication which might or might not work. I now have access to a proxy server so I will get around to testing this, but I didn't want to delay publishing this bit so far.

Link : Java Source.

Next Part : Integrating into a Domino application.

Monday, April 23, 2007

Extending Domino with Java - Part 2 - Simple Java

Now that we've downloaded eclipse, lets install the IDE and take a look. The eclipse install is easy - just unzip the folder to a directory of choice, it doesn't update the registry - simple and easy. I usually navigate to eclipse.exe and add a short cut to the desktop.

When I startup eclipse and I get the following error which means that I forgot to install the JSDK.

After I installed the JSDK eclipse starts up and stops to prompt you for the location of the workspace. I've chosen c:\workspaces\workspace so that I can keep them in one easy to backup location.

Next, close the Welcome screen and you then be in the Java perspective. Perspectives are the way that eclipse organises the files for different users and tasks. The default for the WTP is the Java perspective.

From the File > New > Other select the Java Project and enter an appropriate name and leave the default JRE selected.

The next Step is to get the HTTPClient code that we want to reuse. Using open source code can be hit and miss on the documentation front. Newer versions of projects do not have a great deal of documentation. However, the established project usually have more than enough examples, documentation and tutorials to get you started.

We'll download the HTTPClient 3.1 rc 1 version from the HTTPClient Project. We'll also need the other prerequsite projects, although we can skip the Junit project. Each zip file contains documentation and the *.jar files. These are the libraries that we want to reuse. I usually collect them into one single directory of jars that I want to reuse, in this example c:\lib.

Select the new project and in the properties > java build path select to add external jars. Navigate to the single directory and add each one.

So lets finish with a simple test - to confirm that we've got all the files that we need. There is a complete example in the HttpClient website. Select File > New > Class and enter the name of the class as HttpClientTutorial. The copy and paste the tutorial code. If everything is ok there should be no errors or warnings in the problems tab.

So lets execute the program. Select the java class file in the package explorer and then select run > run as > java application. This runs the class and starts with the main method. In the console tab you should see the html code for the website.

That's it a simple java program that gets the xhtml from a website using a http client. However, in this format is not easy for domino to consume. We will need to be able to pass parameters and decide how to handle errors, essentially hiding some of the complexity.

In the next post we'll build a facade to the HttpClient for use in Domino and add in authentication - ready for integration into a domino java agent.

Sunday, April 22, 2007

Extending Domino with Java - Part 1 IDE

When I answered the post on codestore I was sure that somewhere I had a working sample of domino and the HTTP client code that I did on a very short project. I searched on every dvd archive, thumbdrive and folders on my workstations to no avail.

So what next ?

Well, it didn't take long to write the code in the first place. The projects was only two days worth of consulting (over a year ago), so over the next week (or maybe two) in my spare time in the evenings we'll build it from scratch. To answer Rafaels question - yes I did get the authentication working with the proxy server. However, I don't have access to one for this exercise, so you might have to do some trial and error. I can point you in the right direction though.

It's not a bad idea to revisit the sample and using all of the latest code versions and libraries.

So where should I start ? I don't want to go over stuff that you may already know and I don't want to leave out important steps for the newbies to java and domino. For the experienced you can skip to the bits that interest you.

I think that maybe the first thing to do is start with the a decent Java IDE as Java in the Notes Designer leave a lot to be desired.

For this exercise I'll use Eclipse as its free and is the foundation for Rational Application Developer (RAD) so its familar when you are switching between them. Of course deciding on Eclipse is not that simple as there a few choices for eclipse.

First there is the standard IDE - around 90Mb - great for pure java programming but not many wizards or tools for anything else.

Next there is the Eclipse Web Tools Project (Eclipse WTP) - around 200 Mb - which provides tools for web and j2ee development.

Then there is the Eclipse Callisto Distribution from IBM - around 300 Mb - which bundles Web Tools Platform (WTP), Graphical Modeling Framework (GMF) and
Test and Performance Tools Platform (TPTP).

It's also worth mentioning MyEclipse they have an annual subscription service for a standard version for $30 USD or $50 USD for the professional version. For that you get all the updates plus support.

And the most feature rich of all the eclipse IDE variants is IBM's Rational Application Developer . It also has a price to match - 5,452.99 AUD.

There are other Java IDE's that are out there but I use the eclipse variants because sometime I have to use RAD as that's what the client uses and sometimes they don't have RAD and so the free versions are easier to install for some simple Java development. The bundles are good as they take some of the hard work out of ensuring that all the prerequisite components are installed too.

Lets use Eclipse WTP 1.5.3 and download the 'all-in-one' file from the download area. You'll also need to download a java sdk I would suggest picking one that matches the JVM version supplied with the version of Domino that you are using - that way the IDE will highlight any problems that you would otherwise encounter when you come to include the java code in Domino. So for Domino 6 - that's JSDK 1.3 and for Domino 7.0.2 that is JSDK 1.4.2. We'll use 1.4.2_13 from the Sun archive area.

Anyway that's enough for one night - next session we'll install Eclipse and the Java SDK, download the HTTP client jars and build the first test.

Wednesday, February 07, 2007


I was one of the unlucky ones that didn't make it to LotusSphere 2007, so I have been spending my few free night reading and catching up with the news and opinions rather than posting.

I'm gradually working through the presentations that interest me. I liked Nathans & Chris' interface presentation. I think that stuff like this should be mandatory training for Notes & Domino Developers. Some of the techniques apply just as well to web apps too so it's worth a read.

I learnt early on in my developer career that some nice graphics and icons can make a world of difference to the perception of an application. The investment in learning photoshop has been well worth it.

Anyway back to the reading....

Friday, January 12, 2007

Another J2ee Framework and Another AJAX Toolkit

I came across yet another J2EE framework this week. Open SubSystems and another AJAX toolkit. ThinWire they cleverly also put a page about the differences between Thin Wire and the Google Widget Toolkit. The interesting thing is that with ThinWire you have access to the Full Java API not just the ones available through the Google Widget Toolkit.

The only problem with all of these frameworks and toolkits is which one to choose.

Thursday, January 11, 2007

Locked out of your WAS ?

Somehow I managed to lock myself out of my WAS server during configuration of Domino LDAP - doh! I'd turned on Global Security with the wrong credentials for the LDAP server. After much Googling I finally found the nugget of information to allow me to disable Global Security without the server running.

Want to know what it is ?

WAS_ROOT\bin\wsadmin -conntype NONE


and then wsadmin>quit

It was in a document called "Common Mistakes for Enabling Security" hidden away in the IBM website.

Sunday, January 07, 2007

I've been tagged...

By Carl. So here are five things that you don't know about me.

  1. My first computer was a Sinclair ZX80. I spent a lot of time typing in programs from magazines that never actually worked.
  2. My first car was a Mini Metro Van, which cost me the princely sum of 325 English pounds. I repaired the rust and eventually upgraded the engine from a standard 998cc to a 'tuned' 1398cc with a really LOUD exhaust. It served me well all through University. I had to get a sensible car when I started work, so it got dismantled and the engine is still in the back of my folks garage!
  3. My nickname in University was Sheepy as I was from Wales - great imagination from one of my classmates! If you didn't know the Welsh are rumoured to like sheep - alot!
  4. I once went to a fancy dress party dressed as one fifth of the Village People, my three other house mates and a good friend were the other four. I was the biker guy. We even went to the local pub dressed in full regalia.
  5. I once tried out for a part time job as a barman, but my mental arithmetic was so bad that I only lasted one night.

I suppose I should nominate 5 people. Gareth Cook, Micheal Rice, Simon Hampel and Cali Clarke, if they've not been tagged already.