Skip to main content link. Accesskey S
  • Log In
  • Help
  • IBM Logo
  • IBM Notes and Domino Application Development wiki
  • All Wikis
  • All Forums
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
Community Articles Product Documentation Learning Center IBM Redbooks This category Redbooks Wiki: Best Practices for Domino 8.0 Web Application Development Redbooks Wiki: Building Domino Web Applications using Domino 8.5.1 Redbooks Wiki: Creating Plugins for Lotus Notes, Sametime, and Symphony Redbooks Wiki: Lotus Domino Development Best Practices Custom Search Scope...
Search
Community Articles > API Documentation > Creating an XPages Library
  • New Article
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

IBM contributorMaire Kehoe
Contribution Summary:
  • Articles authored: 18
  • Articles edited: 24
  • Comments Posted: 5

Recent articles by this author

XPages 'compositeData' not found

The custom control autoremove functionality will sometimes result in "'compositeData' not found" error pages.

XPages configuration file format page 5

Other tag definitions. Page 5 of the article on the XPages tag definition format.

XPages configuration file format page 4

Defining complextype tags. Page 4 of the article on the XPages configuration file format.

XPages configuration file format page 3

Defining properties. Page 3 of the article on the XPages configuration file format.

XPages configuration file format page 2

Defining control tags. Page 2 of the article on the XPages configuration file format.

Community articleCreating an XPages Library

Added by Maire Kehoe | Edited by IBM contributor Deanna Drschiwiski on September 20, 2010 | Version 20
expanded Abstract
collapsed Abstract
This article shows you step-by-step how to create an XPages library to package an existing Java control to be used by multiple applications.
Tags: XPages, 8.5.2, getting started
ShowTable of Contents
HideTable of Contents
  • 1 Introduction
  • 2 Create the plugin
    • 2.1 Create a new plugin project
    • 2.2 Copy in the Java classes
    • 2.3 Copy in the config files
  • 3 Create the library
    • 3.1 Create the library class
    • 3.2 Contribute the library as an extension
  • 4 Package the plugin in a feature and update site
    • 4.1 Create a feature
    • 4.2 Create an update site
    • 4.3 Build the update site
  • 5 Example files

Introduction


This article is part of the XPages Extensibility API Developers Guide.

This article shows you step-by-step (with screenshots and code samples) how to create an XPages library to package an existing Java control so it can be used by multiple applications. This assumes you have already created a Java control for XPages in an NSF application. If not, you can begin with the article "Creating a Java Control in an NSF".

If you are already familiar with XPages library contents, you can continue with the article "Blank XPages Library".

The rough steps are:
  1. Move the Java control classes and config files to a new plugin
  2. Implement the XspLibrary class and contribute it
  3. Package the plugin in a feature and an update site
  4. Build the update site and make it available to people who need to install it into Domino Designer

Create the plugin


In Domino Designer, switch to the Java perspective. Select Window - Open Perspective - Other... - Java - OK.

Open Java perspective

Create a new plugin project


From the menu bar, select File - New - Project... - Plugin Development - Plugin Project - Next.

New plugin project

Enter the project name "com.example.xsp".
If you want to save it under source control, you should specify the path in the location field. Otherwise, the default location is fine.
Enable the check box "Create a Java project". The default source and output folders are fine.
Select Next.

New plugin project content

Change the Plugin Version to "1.0.0.qualifier". This will append the current timestamp to the plugin version.
Choose a translatable Plugin Name and enter your company name as the Plugin Provider.
Change the Execution Environment to 1.5 so that it will work with the Notes Client on the Mac operating system.
Disable the first two check boxes: "Generate an activator" and "This plugin will make contributions to the UI".
Select Finish.

If prompted to open the Plugin Development perspective, select Yes. Otherwise, select Window - Open Perspective - Other... - Plugin Development - OK.

Copy in the Java classes


Here's a handy tip when copying Java classes to ensure the copy has the same package name as the original.
Open the Java class in the editor. Copy all of the file's contents then right-click the source folder in the plugin project and select Paste.
This will create the Java class file with the correct package. Alternatively, if you copy the file then you will have to manually create the package first.

Copy the Java classes from your application into the source folder of the plugin project.
com.example.component.ExampleControl
com.example.renderkit.html_basic.ExampleRenderer
You will get compile errors in both classes.

In the application, open the "plugin.xml" file and select the Dependancies tab. Note that there is a dependancy on "com.ibm.xsp.core". That's the dependancy you need.

Application dependencies

Double-click on it in the dependancies list and copy the plugin ID.

Plugin project overview

In the plugin project, open the file "META-INF/MANIFEST.MF" and select the Dependancies tab.
Under the section "Required Plugins", select Add. Paste the plugin ID "com.ibm.xsp.core" in the dialog and select OK.

Add plugin project dependency

Finally, save the changes and the compile errors will go away.

Copy in the config files


In the plugin project, create a new META-INF folder under the source folder.
Right-click the plugin project and select New - Other... - General - Folder - Next.

Create this new folder using these details and select Finish.
Parent folder: com.example.xsp/src
Folder name: META-INF

Create new plugin project folder

There is already a META-INF folder at the project root containing the MANIFEST.MF file. That is the only file that will ever be present in the root META-INF folder but we will be adding files to the "src/META-INF" folder.

Copy in the xsp-config file from the application ("WebContent/WEB-INF/exampleControl.xsp-config") to the plugin project at the location "src/META-INF".
Copy in the faces-config file from the application to the plugin project at the same location, and rename it to "example-faces-config.xml".
You cannot have a file with the name "faces-config.xml" in a library, they should only be present in an application.

Create the library


Create the library class


The XspLibrary is used by the infrastructure to find the names of the config files and other information about this library of controls.

Right-click the plugin project and select New - Other... - Java - Class - Next.

Enter these details and select Finish.
Package: com.example.library
Name: ExampleLibrary
Superclass: com.ibm.xsp.library.AbstractXspLibrary

Create library class

The generated class is like so:


package com.example.library;

import com.ibm.xsp.library.AbstractXspLibrary;

public class ExampleLibrary extends AbstractXspLibrary {

  public String getLibraryId() {
    // TODO Auto-generated method stub
    return null;
  }
}


Your class must extend from the provided default implementation because in later releases other methods may be added to the XspLibrary interface, with a default implementation in the AbstractXspLibrary class.

Right-click the library class (ExampleLibrary.java) and select Source - "Override/Implement Methods".
Enable the check boxes beside the following methods and select OK.
getFacesConfigFiles
getPluginId
getXspConfigFiles

Override library methods

The getDependencies method is not needed because this library will only depend on the core library which is in the default dependancies list. If you needed to extend a control provided in another library you have implemented, you would need to list a dependancy on that other library.
The isDefault method is not needed because this library is not a default library. Only applications that explicitly depend on this library will load it as a prereq.

The getLibraryId method should return "com.example.library". This is the ID that applications will use to depend on this library. We're using a naming convention that should end in ".library".
The getPluginId method should return the plugin's id. The pluginId is necessary in Domino Designer where it is added to the application's "plugin.xml" file so that the application can compile references to classes in the shared library.
In the getFacesConfigFiles and getXspConfigFiles methods, list the faces-config and xsp-config files in this library respectively. Both these methods use "/" as the path separator.

This resulting library class should be as follows.


package com.example.library;

import com.ibm.xsp.library.AbstractXspLibrary;

public class ExampleLibrary extends AbstractXspLibrary {

  public String getLibraryId() {
    return "com.example.library";
  }

  @Override
  public String getPluginId() {
    return "com.example.xsp";
  }

  @Override
  public String[] getFacesConfigFiles() {
    return new String[] {
      "META-INF/example-faces-config.xml",
    };
  }

  @Override
  public String[] getXspConfigFiles() {
    return new String[] {
      "META-INF/exampleControl.xsp-config",
    };
  }
}


Contribute the library as an extension


The XspLibrary is contributed through the Eclipse Extension point named "com.ibm.commons.Extension".

In the plugin project, open the "META-INF/MANIFEST.MF" file. In the Dependancies tab, add a dependancy on "com.ibm.commons" and move it up before the dependancy on the "com.ibm.xsp.core" plugin.

Add plugin project dependency

In the Extensions tab, select Add - "com.ibm.commons.Extension" - Finish.

Add plugin extension

Select the "(service)" entry under the extension then enter the following details and Save.
Type: com.ibm.xsp.Library (same as the service)
Class: com.example.library.ExampleLibrary

Plugin project extension details

Note, that extension is saved to the new "plugin.xml" file which is created in the library plugin. It is edited through the same editor as the "MANIFEST.MF" file.

Package the plugin in a feature and update site


To use the plugin into Domino Designer, you need to create a feature and package it into an update site.

Create a feature


Select File - New - Project... - "Plugin Development" - "Feature Project" - Next.

Enter the following details and select Next.
Project name: com.example.xsp.feature
Feature Name: Example XSP Feature
Feature Version: 1.0.0.qualifier

New feature project

Select your plugin from the "Referenced Plugins and Fragments" list and Finish.

New feature project plugins

Create an update site


Select File - New - Project... - "Plugin Development" - "Update Site Project" - Next. Enter the Project name "libraryUpdateSite" and select Finish.
In the update site, open the file "site.xml". In the "Site Map" tab, select "Add Feature" - "com.example.xsp.feature" - OK. Save your changes.

Update site add feature

Build the update site


In the update site, open the file "site.xml". In the "Site Map" tab, select the button "Build All".

Update site build all

This will build the features and plugins and save the output to the update site in the workspace. If you cannot see the build output, in the "Package Explorer" view, right-click the update site and select Refresh.

If you select "Build All" again, it will rebuild the update site but with a later time stamp in the version. When Eclipse installs from an update site, it will only install the latest version number so copies with an earlier time stamp will be ignored.

The update site is now ready to be installed into Domino Designer. To learn how to do this, you can continue with the article "Using an XPages Library in Domino Designer". If installing it yourself, you can just install from the update site's current folder location or to share it with other developers you can publish it on a web server.

For more information about deployment, refer to the article "Deploying XPages Libraries"

Example files


Download the example files archive. This contains the plugin source, feature source and the update site containing the built plugin and fragment.

To use the example files, switch to the Java perspective and import the example files archive.
Select File - Import - General - "Existing Projects into Workspace" - Next - "Select archive file" - Browse - Finish.
expanded Attachments (17)
collapsed Attachments (17)
File TypeSizeFile NameCreated On
image/jpeg 39 KB updateSiteBuildAll.jpg 9/20/10 2:02 PM
image/jpeg 39 KB addPluginDep1.jpg 9/20/10 2:02 PM
image/jpeg 57 KB addPluginDep2.jpg 9/20/10 2:02 PM
image/jpeg 53 KB addPluginExt.jpg 9/20/10 2:02 PM
image/jpeg 43 KB appDep.jpg 9/20/10 2:02 PM
image/jpeg 57 KB createLibClass.jpg 9/20/10 2:02 PM
image/jpeg 46 KB newFeature.jpg 9/20/10 2:02 PM
image/jpeg 70 KB newFeaturePlugin.jpg 9/20/10 2:02 PM
image/jpeg 41 KB newFolder.jpg 9/20/10 2:02 PM
image/jpeg 58 KB newPlugin.jpg 9/20/10 2:02 PM
image/jpeg 61 KB newPluginContent.jpg 9/20/10 2:02 PM
image/jpeg 33 KB openJavaPerspective.jpg 9/20/10 2:02 PM
image/jpeg 44 KB overrideLibMethods.jpg 9/20/10 2:02 PM
image/jpeg 30 KB pluginExtDetails.jpg 9/20/10 2:02 PM
image/jpeg 43 KB pluginOverview.jpg 9/20/10 2:02 PM
image/jpeg 32 KB updateSiteAddFeature.jpg 9/20/10 2:02 PM
application/x-zip 10 KB exampleLibraryFiles.zip 9/20/10 2:02 PM
expanded Versions (21)
collapsed Versions (21)
Version Comparison     
VersionDateChanged by              Summary of changes
21Sep 20, 2010 2:02:18 PMDeanna Drschiwiski  IBM contributor
This version (20)Sep 20, 2010 2:01:27 PMDeanna Drschiwiski  IBM contributor
19Aug 23, 2010 3:55:58 AMDarin Egan  IBM contributor
18Aug 20, 2010 6:19:44 AMDarin Egan  IBM contributor
17Aug 17, 2010 10:23:50 AMDarin Egan  IBM contributor
16Aug 5, 2010 10:01:12 AMDarin Egan  IBM contributor
15Aug 4, 2010 11:41:39 AMDarin Egan  IBM contributor
14Aug 4, 2010 11:28:29 AMDarin Egan  IBM contributor
13Aug 4, 2010 10:59:58 AMDarin Egan  IBM contributor
12May 25, 2010 11:10:22 AMPadraic Edwards  IBM contributor
11May 21, 2010 5:21:44 AMMaire Kehoe  IBM contributor
10May 21, 2010 5:20:49 AMMaire Kehoe  IBM contributor
9May 21, 2010 5:11:27 AMMaire Kehoe  IBM contributor
8May 20, 2010 1:49:28 PMDeanna Drschiwiski  IBM contributor
7May 20, 2010 11:31:42 AMPadraic Edwards  IBM contributor
6May 19, 2010 8:38:43 AMMaire Kehoe  IBM contributor
5May 19, 2010 8:35:51 AMMaire Kehoe  IBM contributor
4May 19, 2010 7:57:13 AMMaire Kehoe  IBM contributor
3May 19, 2010 7:56:19 AMMaire Kehoe  IBM contributor
2May 19, 2010 7:53:57 AMMaire Kehoe  IBM contributor
1May 19, 2010 7:51:33 AMMaire Kehoe  IBM contributor
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • FacebookIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkIBM Collaboration Solutions
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use