If the standard search methods that the builder offers do not meet your requirements, you can write a custom method that the builder invokes at runtime.
The builder invokes your method through the indirect reference specified in the Custom Search Method
input. Your method must implement the following contract:
- The method must return a java.util.Iterator instance that yields zero or more com.ibm.workplace.wcm.api.DocumentId instances.
These instances identify the exact content or library components that this builder renders and places on the IBM® WebSphere® Portlet Factory page.
- All DocumentId instances must be from the document library specified by the Document Library input.
To make implementing custom methods easier, the builder LJO contains a method that returns a reference to a utility class from which you can obtain a Lotus® Web Content Management workspace. Use this workspace object to search for content and components. The LJO method signature is as follows:
public LWCMDataUtility getLWCMDataUtility(WebAppAccess webAppAccess )
The returned utility class contains a number of methods that the builder itself uses at runtime. However, only the following method is currently supported for use by code outside of the builder:
public Workspace getWorkspace( WebAppAccess webAppAccess ) throws Exception
Because the other methods in this class may change as the builder evolves, do not depend on them being consistent across releases of this builder.
The following sample code demonstrates how to use this utility class to write a custom search method that retrieves images by name.
public class CustomLWCMSearchLJO
private LWCMDataUtility lwcmDataUtility;
public CustomLWCMSearchLJO( LWCMDataUtility lwcmDataUtility )
this.lwcmDataUtility = lwcmDataUtility;
public Iterator getImageByName( WebAppAccess webAppAccess, String imageName )
final Workspace workspace = lwcmDataUtility.getWorkspace( webAppAccess );
return workspace.findByName( DocumentTypes.ImageComponent, imageName );
Adhere to the following guidelines for your code:
- Import various classes that are defined in the IBM Lotus Web Content Management API.
The references to the classes are shown in the sample. Your Lotus Web Content Management installation contains a JAR file named ilwcm.api.jar that defines all the required classes. This JAR file is stored at portal install root/PortalServer/wcm/shared/api.
- Add this JAR file to the Java Build Path of your WebSphere Portlet Factory project to compile the custom code.
- Do not explicitly add this JAR file to your project runtime classpath.
This JAR file is typically included as a shared library in the runtime classpath of all applications on the server.
If you copy the ilwcm.api.jar
file into your project and refer to it from the project, ensure that you do not place it in web-inf/lib
. If you place the JAR file in either of these folders, it can be published with your project and you can receive runtime exceptions when the builder executes.
Parent topic: Lotus Web Content Management Access builder