XPages and Domino 9.0.1 FP2: upgrades to CKEditor and Dojo

IBM released fix pack 2 for Domino and XWork Server 9.0.1 this week. Among many fixes it includes the following fix:

SPR# TMGN9KJTEB – Adds Internet Explorer 11 support for xPages

I asked Brian Gleeson from the IBM Dublin team what exactly this means, and he responded that it covers an upgrade of CKEditor from 3.6.x to 4.3.2 and an upgrade of Dojo from 1.8.3 to 1.9.2.

One issue I have seen so far with CKEditor 4.3.2 is that the “Insert image” button called ‘Image’ in a custom toolbar is different from the standard “Insert image” button used if you use the default toolbar. Instead, you need to use ‘IbmImage’ as the name of the image button.

The latest CKEditor adds a spell check option – either through the default toolbar or by adding ‘IbmSpellChecker’ to your custom toolbar. It’s great that the CKEditor in XPages finally adds that facility. Here it is in action:

CKEditor spell checker

With the new CKEditor the ‘toolbarType’ Dojo attribute no longer works. Instead use ‘toolbar’ as Dojo attribute with Slim, Medium, Large and Full as possible values.

XPages boilerplate: useful code snippets and modules for your next XPages project

When I start a new XPages project, I use lots of code snippets and modules from previous projects. Many of these code snippets and modules are open source or available on blog posts from fellow XPages bloggers. In this blog post I will list some of these useful code snippets and modules and hope that this will inspire you and help you enhance your next XPages project.

Useful code snippets and modules:

You can also take a look at the XPages Scaffolding project by Jesse Gallagher. At least look at the README.md file in which Jesse describes what’s included.

Of course, you should not forget all the useful libraries and tools available in OpenNTF Essentials (both in the Essentials Runtime and in Essentials Toolbox) such as the OpenNTF Domino API, XPages Debug Toolbar and XPages Log File Reader. Also of great value is Auto Logins which provides “remember me” functionality for your app.

IBM Notes 9.0.1 and IBM Domino 9.0.1 are now available for download

IBM Notes 9.0.1 and IBM Domino 9.0.1 are now available for download on Passport Advantage.IBM Notes

This release includes 292 documented fixes (as of this evening). Here’s the “Top 20” fix list according to IBM.

Some of the 9.0.1 part numbers:

  • IBM Notes Client 9.0.1 for Windows English: CIQ7REN
  • IBM Notes Client 9.0.1 for Mac English: CIQ7UEN
  • IBM Notes, Domino Designer and Admin 9.0.1 client: CIQ91EN
  • SwiftFile 4.2.1 for IBM Notes 9.0.1 English: CRP4BEN
  • IBM Domino Server 9.0.1 64 bit for Windows English: CIQ7WEN
  • IBM Domino Server 9.0.1 64 bit for Linux for xSeries English: CIQ7ZEN
  • IBM Notes Traveler 9.0.1 for Windows Multilingual: CIQ7BML
  • IBM Notes Traveler 9.0.1 for Linux for xSeries Multilingual: CIQ7CML
  • IBM Domino Social Edition OpenSocial component 9.0.1 64 bit for Windows English: CIQ85EN
  • IBM Domino Social Edition OpenSocial component 9.0.1 64 bit for Linux for xSeries English: CIQ89EN
  • IBM XWork Server 9.0.1 64 bit for Windows English: CIQ8DEN
  • IBM XWork Server 9.0.1 64 bit for Linux for xSeries English: CIQ8HEN

How to recycle Notes objects in XPages and Java

Using Notes objects in XPages and in Java require that you recycle those objects in order to avoid memory leaks and backend out of memory issues. Here I will summarize how to do proper recycling in XPages for server-side javascript, Java and Java using the new OpenNTF project org.openntf.domino.

Server-side JavaScript

With server-side JavaScript you have to use the recycle method available on Notes objects and you have to “nullify” your server-side JavaScript variables. Thank you, Tony McGuckin, for clarifying this.

Here’s a very simple example that assumes that the variable doc has been initialized elsewhere:

doc.recycle();
doc = null;

Java

In Java you have to use the recycle method available on Notes objects. So for looping through a document collection you have to do this:

try {
	Database dbCurrent = ExtLibUtil.getCurrentDatabase();
	DocumentCollection dc = db.getAllDocuments();
	Document doc = dc.getFirstDocument();
	While (doc != null) {
		// process doc
		tmp = dc.getNextDocument(doc);
		doc.recycle();
		doc = tmp;
	}
	dc.recycle();
} catch (NotesException e) {
	e.printStackTrace();
}

org.openntf.domino

With org.openntf.domino you do nothing with regards to recycling! So when looping through a document collection you can concentrate on your business logic:

Database db = Factory.getSession().getCurrentDatabase();
for (Document doc : db.getAllDocuments())
	// process doc
}

OpenNTF webinars for the open source community

logo

OpenNTF has announced a new initiative called OpenNTF Webinars.

The first webinar takes place tomorrow, Tuesday May 7, and is all about OpenNTF. Join the web meeting and hear Bruce Elgort, Serdar BasegmezJesse Gallagher, Niklas Heidloff, Peter Tanner and me talk about OpenNTF and about what OpenNTF can offer the open source community.

Future webinars will be announced at the webinar landing page.

How to force a reload of JS and CSS files when changed

Caching of Javascript and CSS files is great and really improves performance in the browser. But caching also means that changes to the files are not picked up. So how do you get the browser to automatically reload the files when you have updated them because of new requirements, bug fixed etc.?

There are several ways to achieve this. On Apache you can for instance use the modpagespeed module that automatically changes links to resources when the backend resource files change. Other ways include manually adding a version number to your resources (?version=1234), and changing the file name of the resource.

For IBM Domino, IBM XWork Server and XPages you can of course manually change the file name of your resources when content changes (and remember to update references to those files in your code). A better method is to create your own versioning system for your resources based on the idea of adding a unique id to the link to the resources. The following describes this method.

You can add a version number to an application scoped bean and then update that version number whenever you want the browser to reload your resources. Here’s a code snippet for such a version number bean (this is only some of the stuff needed for a bean – see my blog post about creating a bean for more details) :

public class Config implements Serializable {
	private static final long serialVersionUID = 6469339826789980362L;
	private static final String version = "20130410";

	public static String getVersion() {
		return version;
	}
}

Using this bean I can then create links to my Javascript and CSS files like this:

<xp:this.resources>
	<xp:script clientSide="true">
		<xp:this.src><![CDATA[${javascript:"/jsCommon?open&v=" + config.getVersion()}]]></xp:this.src>
	</xp:script>
	<xp:styleSheet>
		<xp:this.href><![CDATA[${javascript:"/custom.css?open&v=" + config.getVersion()}]]></xp:this.href>
	</xp:styleSheet>
</xp:this.resources>

The links then look like this in the browser:

db.nsf/custom.css?open&amp;v=20130410
db.nsf/jsCommon?open&amp;v=20130410

Whenever I want to force a reload, I then update the version string in my Config bean. The resources are then reloaded.