XPages: 2 very easy performance optimization tricks

Here are 2 very easy ways to optimize performance for your XPages applications:

  • Enable “Use runtime optimized JavaScript and CSS resources” to have your JS and CSS files combined into fewer files. This reduces the number of HTTP requests that the browser has to make against your server and application and thereby makes the site load much faster.
  • Select “GZip” as the compression method to have your Domino server compress files and images. This reduces the amount of data that the browser has to retrieve from your server and application which again makes your application load much faster

Both of these settings are in Application Properties on the XPages tab.

Once you have done those two, you now have more time to go into detailed performance optimization and look at optimizing backend code, server settings, and much more. Tim Tripcony has answered a question in the XPages Development forum about performance optimization that has a lot of details about performance optimization.

Learning XPages: available resources

I often hear people new to XPages ask: what resources are available if you want to learn XPages?

The following lists (some of the) available resources if you want to learn XPages.

IBM provided resources

Books

Free community provided resources

  • XPages.info: lots of links to useful resources
  • XPageswiki.com
  • XPages.TV:  Notes In 9 videos, 2 hours of XPages jumpstart, and a introduction to Java for XPages develovers series
  • XPagescheatsheet.com: home of the original XPages cheatsheet and the new Social Tools cheatsheet

Free courses

Paid courses

Community provided support

Blogs
  • There are lots of blogs that cover XPages. Keep an eye on the XPages.info/news section that is updated daily with links to blog entries, wiki articles, OpenNTF projects and more.
Twitter
Happy XPages learning!

Creating your first managed bean for XPages

With Java and managed beans you can make your XPages applications even more powerful. In this blog post I will go through the steps to create and use a managed bean in XPages.

I am using Lotus Notes and Domino Designer 8.5.3 and will therefore use the new Java design element for the Java code located in the Code section.

In short: use “New Java Class” to create a Java class. Give your new class a package name (e.g. com.company) and a class name (e.g. HelloWorld). Add a local variable and let Eclipse generate getter and setter for it by using Source – Generate Getters and Setters. Also, let Eclipse generate a public no-parameter constructor by using Source – Generate Constructor using Fields and deselect your newly created field and omit call to super().

You will then have the following basic skeleton for a Java class:

package com.company;

public class helloworld {

	public helloworld() {
	}

	private String someVariable;

	public String getSomeVariable() {
		return someVariable;
	}

	public void setSomeVariable(String someVariable) {
		someVariable = someVariable;
	}

}

In order to support the XPages server page persistence option “Keep pages on disk”, the Java class needs to be serializable. The Java class therefore needs to implement Serializable. Therefore, add “implements Serializable” after your class name (and Eclipse will automatically add the required import). Then use the Eclipse Quick Fix to “Add generated serial version ID”. You now have a basic skeleton for a Java class that can be used as a managed bean:

package com.company;

import java.io.Serializable;

public class helloworld implements Serializable {

	private static final long serialVersionUID = 6469339826789980362L;

	public helloworld() {
	}

	private String someVariable;

	public String getSomeVariable() {
		return someVariable;
	}

	public void setSomeVariable(String someVariable) {
		someVariable = someVariable;
	}

}

Now we need to tell XPages that we would like to use this Java class as a managed bean. First, Add the Package Explorer view to your Eclipse perspective using Window – Show Eclipse Views – Other and select Package Explorer. Now go to the Package Explorer and navigate to the WebContent/WEB-INF folder where you will find a faces-config.xml file. Open the faces-config.xml file and add the following managed bean section in the <faces-config> section:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
	<managed-bean>
		<managed-bean-name>helloWorld</managed-bean-name>
		<managed-bean-class>com.company.helloworld</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
</faces-config>

You now have a basic faces-config for your HelloWorld Java class. Scope for a bean can be the usual scopes (application, session, view, request).

With the Java class and the faces-config in place the managed bean can now be used in an XPage. The bean value (both the getter and setter) can be accessed from an XPage using #{helloWorld.someVariable}.

This very basic example of a bean does not do anything. The Java class would of course have to add values to the someVariable property before that value would be useful in an XPage. I will create a 2nd blog post that shows how to use a bean in a repeat control to display values from the managed bean.

For more information on XPages and managed beans have a look at: