3 XPages hints #3: Homepage and Performance improvements

3 XPages hints #3: Homepage and Performance improvements

Finally another blog post 🙂 hope these 3 hints will help you or will help you some day in the future.

In this series of XPages hints i included also a NSF File in which the described hints are implemented. But beware, it is not a design highlight 🙂 i wanted to keep it as simple as possible. The Extension Library is needed to run the examples (from openntf.org or the included version in Domino 9.x).

Hint 1: Always define a home page

Usually every applicatino has 1 point of entry, a homepage. This can be set in the Database Properties for the Notes Client and for Web Access. For the Web Access it works, kind of.. the XPage setted in the settings will open, but this setting has a serious drawback: it opens the application with the URL: “host/directory/database.nsf” instead of “host/directory/database.nsf/myxpagehome.xsp”. So relative urls for images, javascript and css files might not work when opening the application with the “.nsf” ending. As soon the user switches to another XPage, these resources work again. In order to prevent this, it’s a good practice to have always a “home.xsp” XPage, and this XPage will redirect the user, server side, to the actual entry page.

This is a way how you can achieve this:

1. Create a Managed Bean “ApplicationController”
Create a new Java Class and create a function which gets the XSP Context and trigger it’s redirectToPage method. Let’s say we want the XPage “xpageshints3.xsp” to be the first page to open, when the application loads, so we set the REALHOMEPAGE constant accordingly.

package ch.fdehedin.controller;

import java.io.Serializable;

import javax.faces.context.FacesContext;

import com.ibm.xsp.designer.context.XSPContext;

public class ApplicationController implements Serializable {

	private static final long serialVersionUID = 1L;
	private static final String REALHOMEPAGE = "xpageshints3.xsp";

	 * getting the XSP Contect and redirect
	public void redirectToRealHomePage() {
		try {
		} catch (Exception e) {

	public XSPContext getXSPContext() {
		return XSPContext.getXSPContext(getFacesContext());

	public FacesContext getFacesContext() {
		return FacesContext.getCurrentInstance();

2. Register this class as a Managed Bean in the faces.config. We can even use the “application-scope”, since we need only 1 instance, but consider using the “session-scope” and you can use this technique to have user role dependant home pages.


3. Create a “fake” XPage homepage and call the “redirectToRealHomePage” function. Let’s name this page “home.xsp”

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" beforePageLoad="#{applicationController.redirectToRealHomePage}">

4. Register the newly created XPage in the Database Properties


Now you’re ready to go.. call the database with the “**.nsf” url, and the home.xsp will automaticaly redirect to your real homepage.

Another way to achieve this is to manipulate the Internet Site Documents on the server, but personally i prefer the above method described.

Hint 2: Use Dojo Dynamic Content Control to boost your XPages performance

With the Dojo Dynamic Content Control you can decide that some time consuming elements of you XPage are loading after (asynchronous) the main XPages has been loaded and displayed in the browser.

IBM Connections uses this technique pretty often: The main parts of a page is being loaded instantly and other parts are being loaded later with a spinning circle symbol. So the page is actually not loaded faster, but you can decided that important parts are being loaded instantly and not so important parts are being loaded later. This will result in a better user experience (the page loads emotionally faster)..

So what’s the use case?
In one of my recent XPages Applications i was working on, the main Form was pretty simple, but on the sidebar on the right of the form we had to display depending data from several other databases and some of them are pretty large.. So when the form was loaded, it always took some time due to the lookup to the other databases. In this case the Dojo Dynamic Content came pretty handy: we decided that the data from the other databases will load asynchronous with the Dojo Dynamic Content while the main Form loaded instantly.

I prepared a little example:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" xmlns:xe="http://www.ibm.com/xsp/coreex">
 Wait until the following content has loaded:
 <xe:djContentPane id="pnlContentPange" partialRefresh="true"
 <xp:text escape="true" id="computedField1">
 #{javascript:var startTime = new Date().getTime(); // get the current time
 while (new Date().getTime() < startTime + 3000){};return "finished loading!"}




Hint 3: Use Java Managed Beans instead of ServerSide Javascript for better performance

Maybe many XPages developers might moan up by this title.. Javascript is totally fine, i love JQuery and i started to like DOJO, but for me it’s not the programming language to pick when it comes to complex applications with a lot of business logic. Don’t get me wrong, if you’re a Javascript crack, doing reusable components, centralise the code in libraries, than that’s totally fine.

I’ve seen application containing XPages with over 2’500 lines of code(!) with totally mixed XPages XML, inline CSS, ServerSide and ClientSide Javascript functions and i do not want to be the poor soul who has to enhance or maintain this mess. Sooner or later applications like this will run into serious problems in terms of maintainability and performance.

When we speak about performance: i did a little comparison with 2 buttons doing exactly the same thing: they simply feed a string array with 3’000’000 entries.. Let’s start the race:


Java Managed Bean: The method is in a managed bean, which resides in request scope. It runs not even 1 second on my machine (fairly old Macbook Pro with a Windows VM). When the bean would be in session or view scope it might run even quicker..

ServerSide Javascript: The method is inside the XPage. It runs roughly 13 seconds (!).. sometimes it even ran into the partial refresh timeout and i had to extend it.


Download the examples as NSF File.

Download Lotus Notes nsf File

Leave a Reply