XSnippets: code snippets for XPages

The beta version of XSnippets was recently announced by Niklas Heidloff on the OpenNTF blog. XSnippets is a code repository of useful XPages code snippets that OpenNTF contributors can contribute to. If you have useful code snippets then consider adding them to XSnippets.

I have added my first code snippet to XSnippets based on my blog entry on how to control the HTTP response status code in XPages:

I am a member director on the OpenNTF board of directors

As previously blogged my company PHL Consult and I support OpenNTF and open source. To further show my support I nominated myself for one of the 9 member director positions in the OpenNTF board of directors.

The board of directors for the newly incorporated OpenNTF has now been set and I am happy to have been elected to be part of the board (for one year). The new board had its first board meeting last Thursday and I look forward to be able to add value to OpenNTF.

My 1st year as self-employed consultant at PHL Consult

One year ago I started as self-employed consultant at my own company PHL Consult after having worked for IBM for 16 years – and what a great year! Starting on my own has proved to be one my of my best decisions ever.

It has been a year of classic Lotus Notes application development work, XPages development work, teaching courses and much more. I started with one customer and have since then been doing work for 10 other paying customers and been involved in proposals for a handful more. Furthermore, I reviewed David Leedys XPages cheat sheet, and reviewed the IBM course “Modernizing Lotus Domino 8.5.2 Applications”.

This year I also became member of the boards at NotesNetDanNotes and OpenNTF.

The following are public sites that I have implemented for customers during my 1st year:

Lessons learned (and assumptions confirmed):

  • Networking is important: several of my customers have chosen me for their work because we were connected in some way.
  • Advertising helps: I advertise my business services on the Google advertising network and know for a fact that some customers came to me via that channel.
  • Being social: I am a strong believer in blogging and social networks and the impact that it can have on you and others.

I look forward to the next year and what it will bring me of interesting work and projects.

One final advice: pursue your dream!

Going to Lotusphere 2012

Lotusphere 2012 takes place January 15 – January 19, 2012 in Orlando, Florida – and I am very happy to report that I will participate in the conference. This will be my first ever Lotusphere in the US (I participated in the Lotusphere conference in Berlin in 1999).

I arrive Friday evening (January 13) and leave again Thursday evening (January 19). I will be staying at the Disney’s Yacht Club Resort, if you need me 🙂

I look forward to meet a lot of interesting people from the Lotus community – most of whom I have only been in contact with through blogging, Twitter, Skype, mails etc. and never met before. See you soon!

Update: I have created a Lanyrd event for Lotusphere 2012.

Lotus Notes/Domino 8.5.3 and IBM XWork Server 8.5.3 are here

It’s October 4th and Lotus Notes and Domino 8.5.3 are now available for download on Passport Advantage. The brand new IBM XWork Server has also been announced.

I have been looking forward to this release in general, and in particular because of features specifically for XPages developers:

  • improved JavaScript editor
  • finally a java design element for XPages
  • Dojo 1.6.1
  • OneUI version 2.1 (which looks very similar to the prototype 3.0 version that the Lotus Notes and Domino Application Development wiki uses)
  • option to combine CSS and JS in a single file to improve site speed
  • improved HTML5 support such as support for adding HTML5 attributes
  • source control enablement
I look very much forward to an improved experience when working with XPages development in the Domino Designer client. Happy coding!

Integrating a Lotus Notes application with Exchange

I recently finished a project with the purpose of integrating a Lotus Notes CRM application with Microsoft Outlook and Microsoft Exchange. The customer has moved their mail handling to Exchange and Outlook and still uses Lotus Notes for their application handling including this CRM application. The CRM application had functionality to import mails from Notes, send mail from Notes, and create and maintain meeting invitations. My task was to make this functionality work with Exchange and Outlook instead.

In order to integrate with Exchange I used the Exchange Web Services (EWS) Java API and created a Java class with the necessary jar files imported that is responsible for the interface between the existing Lotusscript logic and the EWS API. The Lotusscript logic then uses LS2J to use the methods in the Java class.

With Exchange Web Services installed on the Exchange server the Java API can access the web services using the WSDL at /EWS/Service.wsdl (through an endpoint called /EWS/exchange.asmx).

To allow the Lotus Notes client to communicate with the Exchange server I needed to change the java.policy file in order to add: permission java.net.NetPermission “setCookieHandler”, “write”;. To automate this I used this Lotusscript code by Darren Oliver that checks the java.policy file for a specific permission policy and if not found adds the permission policy.

At first I wanted to use Exchange Impersonation to allow a single Windows Active Directory account to be able to act on behalf of others users on a Exchange mailbox. This decision was later changed to use the individual users own credentials. The user is prompted for their password and this is stored encrypted for their use only in a profile document. The following code snippet shows how communication with the Exchange server is set up in Java using the EWS API:

service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
// service.setTraceEnabled(true); // enable to trace the web service communication in the Java debug console
service.setUrl(new java.net.URI(server));
ExchangeCredentials credentials = new WebCredentials(userid, password);
service.setCredentials(credentials);

A meeting is simply created using the Appointment class. Time zone support is achieved by using UTC as the time zone for date details. To format dates as UTC I used the LSGMTTime  property of the NotesDateTime class.

Appointment appointment = new Appointment(service);
appointment.setSubject(subject);
appointment.setBody(MessageBody.getMessageBodyFromText(body));
appointment.setStart(formatter.parse(startDate));
appointment.setEnd(formatter.parse(endDate));
appointment.setLocation(location);
// Save as appointment - and not as a meeting with participants
appointment.save(SendInvitationsMode.SendToNone);

Importing mails is done by presenting the user with a list of mails from the users Exchange mailbox. The list is retrieved by looping through the Inbox folder:

ItemView view = new ItemView(100);
view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);
FindItemsResults<Item> findResults;
findResults = service.findItems(WellKnownFolderName.Inbox, view);
service.loadPropertiesForItems(findResults.getItems(), new PropertySet(BasePropertySet.IdOnly, EmailMessageSchema.Subject, EmailMessageSchema.DateTimeReceived, EmailMessageSchema.Sender));

The user then selects a mail from the list and the corresponding mail in Exchange is retrieved with the unique item id as identifier.

EmailMessage message = EmailMessage.bind(service, new ItemId(mailItemId));

Rich text support between Notes and Outlook is handled using Lotusscript stream and mime classes:

Set stream = session.CreateStream
Call stream.WriteText(mailBody)
Set mime = doc.CreateMIMEEntity("Body")
Call mime.SetContentFromText (stream, "text/html;charset=UTF-8",ENC_NONE)

When sending mails from the Notes CRM application the user can access their Outlook contacts. The list of Outlook contacts is retrieved by looping through the Contacts folder:

ItemView view = new ItemView(2000);
view.getOrderBy().add(ContactSchema.DisplayName, SortDirection.Ascending);
FindItemsResults<Item> findResults;
findResults = service.findItems(WellKnownFolderName.Contacts, view);

The Microsoft Outlook client is launched when a meeting invitation is created in order for the user to finish the meeting invitation in Outlook. This is achieved by using the Shell Lotusscript command together with the fact that Outlook can be launched with a parameter that indicates what item to open when launched:

Shell( getOutlookPath() + " /select outlook:" + Ucase(doc.OutlookUniqueId(0)) )

The use of LS2J led to some performance issues at the customer site in the form of 10-20 seconds load times before a document was opened. The reason for this is that the Java code is extracted to disk whereby the Antivirus program at use at the customer site started to check all files for virus before the document could be opened. The customer modified the Antivirus settings to remove this check whereby the documents opened within reasonable time again.

DanNotes: The 46th Danish LUG conference is in November

DanNotes is the Danish Lotus user group. It started as a Lotus user group back in 1993 and has since then organized 2 day conferences for the Danish Lotus community with a schedule of 2 a year. The next conference in November is conference number 46! That’s an impressive number of conferences.

I am proud to have been selected as member of the board at the spring conference in May and I am thereby part of the group of organizers that plan the next conference.

I am really looking forward to meet Anders Holm Petersen who is the new country manager for IBM Collaboration Solutions in Denmark, to meet our great lineup of speakers: Niklas Heidloff, Stuart McIntyre, Ulrich Krause, and Chris Connor – and also to meet the many members of the Danish Lotus community.

If you are interested in joining the conference, then head over to the DanNotes website and register. There is a LinkedIn event and a Lanyrd event for the conference if you are interested in tracking the conference using social tools.

PHL Consult supports OpenNTF and open source

My company, PHL Consult, became member of OpenNTF in August and thereby supports OpenNTF and the use of open source within the Lotus Domino/XPages community. This means that I support the idea of open source in general (and support OpenNTF as an organization) – and that I both contribute code to and reuse code from OpenNTF. I have so far contributed 2 open source XPages custom controls to OpenNTF:

At the time of writing this blog post OpenNTF has 23 company members. Members according to OpenNTF are “companies with the common interest to provide open source for IBM Lotus Notes and Domino and to encourage broad industry use of these applications. To achieve these goals members are willing to devote resources or participate in other ways”.

I am teaching two XPages courses in August

I will be teaching two 3-day courses in August, 2011 on basic XPages application development. The courses are arranged by Intravision.

The first 3-day course starts August 23 at IBM in Lyngby. Seats are still available if you are interested in signing up for the course. Please see the course details (in Danish) for more information on how to sign up.

The second 3-day course takes place the week after and is a closed course for a group of developers from the same company.

XPages: only show content for authorized users

Today I was asked: how do you make sure that anonymous users do not see content that only logged on (and thereby authorized) users must see?

I often use a simple solution of having a xp:panel for anonymous users and another xp:panel for authorized users (both on the same XPage). Only one of the two panels are rendered based on whether the user is logged or not. So the two xp:panels would look like this:

Panel 1: for anonymous users

<xp:panel>
<xp:this.rendered><![CDATA[#{javascript:@UserName() == "Anonymous"}]]></xp:this.rendered>
You must log on to see contents.
</xp:panel>

Panel 2: for authorized users

<xp:panel>
<xp:this.rendered><![CDATA[#{javascript:(@UserName() != "Anonymous"}]]></xp:this.rendered>
This is the secret content.
</xp:panel>

You can combine this with the XPages Dojo Login Custom Control available on OpenNTF so that the user can stay on the page when logging on instead of going to a seperate login page.