Portlet Factory, Version 6.1.2
About custom search methods
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 WCM workspace. Use this workspace object to search for content and components. The LJO method signature is as follows:
public LWCM DataUtility getLWCM DataUtility(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 ExceptionBecause 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.
package com.ibm.wpf.samples; import java.util.Iterator; import com.bowstreet.builders.webapp.methods.LWCM DataUtility; import com.bowstreet.webapp.WebAppAccess; import com.ibm.workplace.wcm.api.DocumentTypes; import com.ibm.workplace.wcm.api.Workspace; public class CustomLWCM SearchLJO private LWCM DataUtility lwcmDataUtility; public CustomLWCM SearchLJO( LWCM DataUtility lwcmDataUtility ) { this.lwcmDataUtility = lwcmDataUtility; } public Iterator getImageByName( WebAppAccess webAppAccess, String imageName ) throws Exception { 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 Workplace WCM ™ API.
The references to the classes are shown in the sample. Your WCM 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 deployed on the server.
Note: 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 or web-inf/work/lib. If you place the JAR file in either of these folders, it can be deployed with your project and you can receive runtime exceptions when the builder executes.
Parent topic: Lotus WCM Access builder
Library | Support |