Thursday, October 04, 2007
SNTT : The value of OO and reuse
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.
<scm:email>
<head>
<style type="text/css">
....
</style>
</head>
<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"/>
</td></tr>
<tr><td bgcolor="#990033" color="white"><h1>New Resources are available online</h1></td></tr>
<tr><td>
<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/>
</p>
</td></tr>
<tr><td bgcolor="#990033">
<p class="footer"><img src="http://www.somewebsite/x.nsf/footerlogo.jpg"/></p>
</td></tr>
</table>
</scm:email>
I looked at the shared action that was currently used to send an registration emails.
Set confirmMessage = New SCMTemplateMailMessage(session,note)
confirmMessage.SendTo = note.email(0)
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 = note.email(0)
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.
Done.
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
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 HTTPFacade.java 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("www.openntf.org");
dhttp.setWebsiteCredentials("username", "password");
String url = "http://www.openntf.org";
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("au.com.scius.examples.HTTPFacade")
Set dhttp = myClass.CreateObject()
Call dhttp.setHost("www.openntf.org")
iReturn=dhttp.executeMethod("http://www.openntf.org")
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 java.io., java.net and java.util packages to create your own HTTPClient as in Julians urlFetcher database.....or maybe just use his database.
Summary.
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
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 selectedMay 17, 2007 9:23:16 PM
org.apache.commons.httpclient.HttpMethodDirector processWWWAuthChallengeINFO: No
credentials available for BASIC 'By Invitation Only'@web:80
A quick look at the documentation and a few refactors later I ended up with the following addition to the original code.
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.if (this.isWebsiteCredentialsUsed())
{
client.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds =
new UsernamePasswordCredentials(this.getWebsiteUser(),
this.getWebsitePassword());
client.getState().setCredentials(new AuthScope(this.getHost(),
this.getPort(),
AuthScope.ANY_REALM),
defaultcreds);
}
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
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 apache.org 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
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
Blog-reading
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
The only problem with all of these frameworks and toolkits is which one to choose.
Thursday, January 11, 2007
Locked out of your WAS ?
Want to know what it is ?
WAS_ROOT\bin\wsadmin -conntype NONE
wsadmin>securityoff
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...
- My first computer was a Sinclair ZX80. I spent a lot of time typing in programs from magazines that never actually worked.
- 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!
- 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!
- 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.
- 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.
Monday, December 18, 2006
Jave EE 5 SDK includes beta JSR168 container
So what does a Portal give me and what does a Portlet container ?
A portlet container runs portlets and provides them with a runtime environment. The runtime environment manages the portlets lifecycle and persistent data for the portlets preferences. JSR168 is the portlet specification, if you write portlets to this specification you can use them on any portal server that supports the JSR168 specification.
A portal is a web application and provides a presentation layer, security, personalisation and aggregation from different sources. The way in which this functionality is implemented varies from vendor to vendor.
Monday, December 11, 2006
Book:Agile Java Development
The books takes you through a small project to create a timesheet application from requirements to finished product using the Agile methods. The author also described other necessary parts of the development process not just Agile, Spring and Hibernate. He covered UML, and setting up ANT and JUNIT. He also includes his personal opinions on things like "Why Agile Modelling and Extreme Programming?". I was very please to see that he thought setting up code directory structure, ant and junit upfront was vital to a projects success. All of which resonates with my own personal opinion that this builds the foundations for a smoother project.
The reasons for my interest in Spring and Hibernate, stems from my Domino and Notes roots. One of the important areas that keeps Notes and Domino in demand is that it has an easy to use database implementation and easy to program environment. Historically, in J2EE projects storing of data somewhere has been the area that required lots of effort. As a result there has been a proliferation of persistence frameworks, such as Hibernate, Ibatis, JDO and Toplink that have been designed and written to simply J2EE persistence. The other area is the general MVC framework for web application development. Spring is one of the leading (or most talked about) modular frameworks for web application development, which includes a flexible MVC web application framework, AOP, JDBC abstraction layer and integration with Hibernate, Ibatis, JDO and Toplink.
I've used Struts and Ibatis in other projects and they are not exactly easy to use and so I was keen to read about spring and hibernate. It seems that everyday J2EE is becoming easier and quicker. The net impact is these frameworks, which speed up development, have the potential to make J2EE applications another option for projects where Domino has been traditionally chosen.
Sunday, December 10, 2006
WebSphere Sales Professional 2006
I'm not entirely convinced of the value of the test. All it really proves is that you can memorise a few key messages from a 40+ page presentation. The Lotus test was a little harder IMHO as there were more material to remember. However, as with most things the devil is in the detail.
Thursday, December 07, 2006
Lotus Solution Sales Professional 2006
Now my boss wants me to sit the Websphere Solution Sales test...
Monday, December 04, 2006
Virtual ANT and a new Portal 6.0 Redpiece
Virtual ANT
There is also a new redpiece available Best Practices for Migrating to IBM WebSphere Portal 6
Sunday, November 26, 2006
Friday, November 24, 2006
Interface Matters

It's not a reason give up and produce poor interfaces, its just that Domino web apps and Notes apps do not have a monopoly on bad user interfaces.
Wednesday, November 15, 2006
Introduction
I was so energized by the Ed Brill presentation, that I decided that it was time for me to get involved in the Lotus community and start a professional blog, rather than the one I've been using to keep family and friends up-to-date.
I couldn't decide what should be the first post. I thought that perhaps an introduction would be good. I'm really not that interesting, so here is a little about me in bullet points.
- Left University with Degree in Computer Science.
- Started working for Lotus UK on the Help Desk, supporting Notes v2.1, cc:Mail and Organiser.
- Left Lotus and started working at a UK start up for a large US Lotus Business Partner.
- Left the Business Partner to start contracting.
- Started contracting for Lotus Consulting UK.
- Decided to have a quick look at what Sydney, Australia had to offer.
- Started on Contract with Lotus Consulting in Australia, which then became/merged with IBM Software Group Services.
- Got married.
- Left IBM to working in a finance organisation.
- Had two children and became an Aussie.
- Left the finance organisation and started working for a large Australian IBM business partner.
So far during my career, I've built solutions for clients using Lotus Notes/Domino and related products (Quickplace, Domino.doc, Workflow..even ViP for those that remember). In the last couple of years I've been more involved with the Java/J2EE world which I find interesting. So far I've been using IBM products such as WAS, Portal and Rational Application Developer - but have been keeping my eye on the open source products.
I've also become interested in the Project Management discipline and recently been deemed competent to be certified as a Registered Project Manager (RPM) with the Australian Institute of Project Management.
However, I'm still a techie at heart....
...and if you are wondering, the quick look at Australia became a little more permanent.