+

Search Tips   |   Advanced Search

Create a context processor class

When configured, a context processor plug-in is invoked by the web content viewer portlet before rendering and allows the current context, such as the item to display, to be modified.

To create a context processor plug-in, create a context processor class and then register the context processor class by deploying it on the server and selecting it from within a Web content viewer portlet.

  1. Create a Java class that implements the interface com.ibm.workplace.wcm.api.ContextProcessor. This class must implement the following method:
    /**
        * Processes the supplied <i>ContextProcessorParams</i> and updates parameters within
        * as necessary     * 
        * @param p_currentSession The current Http Session
        * @param p_contextProcessorParams The editable <i>ContextProcessorParams</i> object 
        */
       public void process(HttpSession p_currentSession, ContextProcessorParams p_contextProcessorParams);
    

    See the Javadoc for further information.

  2. Implement the process method. This method contains the code that is executed when the plug-in is invoked and allows us to modify the current context using the ContextProcessorParams object before the current context is rendered.

  3. A plugin.xml file is needed whether the deployment is done using a WAR or EAR, or using a loose jar. If deployed using an application in a WAR or EAR, include the plugin.xml file in the application "WEB-INF" folder. When using a jar, include the plugin.xml in the root of the jar.
    <?xml version="1.0" encoding="UTF-8"?>
    <plugin id="SampleContextProcessorPluginId" 
    name="SampleContextProcessor" provider-name="IBM" version="1.0.0">
        <extension point="com.ibm.workplace.wcm.api.ContextProcessor" 
        id="SampleContextProcessorPlugin" >
            <processor class="com.acme.SampleContextProcessor"/>
        </extension>
    </plugin>
    

  4. Edit the settings of the web content viewer portlet to associate with the context processor:

    1. Go to the "configuration" or "edit shared settings" view of a web content viewer portlet.

    2. Go to Advanced Options > Plugins

    3. Select a context processor plug-in.

Naming conventions:

If you create a plug-in application with the same names and IDs as an existing plug-in, the new plug-in may override the first. When creating plug-in applications ensure that the following are unique across the system:


Parent: Create custom plug-ins