Package com.ibm.portal.theme.plugin

This package defines ways to contribute content to defined "extension points" in the theme.

See:
          Description

Interface Summary
Reusable Tags an implementation as "reusable".
ThemeContent A generic interface for theme content.
ThemeContext Describes the current theme context.
ThemeInclude A ThemeInclude is a theme contribution responsible for its own rendering.
ThemeItem A ThemeItem is a theme contribution which defines its data and delegates rendering to the theme JSP.
ThemeJspInclude A ThemeJspInclude is a ThemeInclude theme contribution which renders itself by invoking a JSP.
ThemeLinkItem A theme contribution that creates a URL.
ThemeTextItem A theme contribution that contributes simple text.
 

Package com.ibm.portal.theme.plugin Description

This package defines ways to contribute content to defined "extension points" in the theme.

Package Specification

The interfaces presented here can be used to generate content to contribute to defined points in the theme.

There are two main types of objects to contribute to the theme: Theme Items and Theme Includes. An item contributes it's content directly to the page, while an include is rendered via the RequestDispatcher. An extension point should allow only items or only includes. Extensions are instantiated each time they are used via the IConfigurationElement#createExecutableExtension method.

Default extension points:

The table below describes the extension points included in the default theme. The ID field is the extension point identifier used in the plugin.xml. The Suggested Interface field describes the interface which provides the information the default extension point requires. Type enforcement is not performed at runtime. However, if an implementation does not provide at least the information required by the Suggested Interface, the extension may not display correctly in the theme.

 ID   Description   Content Type   Suggested Interface 
 com.ibm.portal.theme.plugin.MetaTagDataItems   provides components with a method of adding data to the meta tags of a page   Theme Item   ThemeTextItem 
 com.ibm.portal.theme.plugin.Styles   provides components with a method of contributing CSS styles to the page   Theme Item   ThemeTextItem 
 com.ibm.portal.theme.plugin.JavascriptItems   provides components with a method of adding javascript to a page   Theme Item   ThemeTextItem 
 com.ibm.portal.theme.plugin.HorizontalPageBarItems   provides components with a method of adding jsp content to the horizontal page bar   Theme Include   ThemeJspInclude 
 com.ibm.portal.theme.plugin.VerticalPageBarItems   provides components with a method of adding jsp content to the vertical page bar   Theme Include   ThemeJspInclude 
 com.ibm.portal.theme.plugin.MainContextMenuItems   provides components with a method of adding an item to the main context menu   Theme Item   ThemeLinkItem 
 com.ibm.portal.theme.plugin.PageContextMenuItems   provides components with a method of adding an item to the main context menu   Theme Item   ThemeLinkItem 
 com.ibm.portal.theme.plugin.PortletContextMenuItems   provides components with a method of adding an item to the portlet context menu   Theme Item   ThemeLinkItem 
 com.ibm.portal.theme.plugin.Flyouts   provides components with a method of adding a flyout to the page   Theme Include   ThemeJspInclude 

Extension point definition examples:

Please note that all markup in this section is implementation specific. The parsing of the plugin.xml is handled by the implementing extension through the setInitializationData method.

Defining a page link extension:

<extension point="com.ibm.portal.theme.plugin.MainContextMenu">
                <item id="AdministrationLink"
                         class="com.ibm.wps.theme.plugin.impl.DefaultThemePageLinkItemImpl"
                         title="helloworld.title"
                         description="helloworld.description"
                         ordinal="2"
                         contentNode="wps.Administration" / >
</extension>
Defining a jsp include extension:
<extension point="com.ibm.wps.plugin.theme.Flyout">
        <include id="PeopleAwareFlyout"
                    class="com.ibm.wps.theme.plugin.impl.DefaultThemeIncludeJspImpl"
                    ordinal="2"
                    jsp="PeopleFlyout.jsp" />
</extension>

Coding examples:

Consuming extensions in JSPs:

For a complete definition of the JSP tags, please refer to the Infocenter.

Theme Item extensions

<portal:themeExtension id="com.ibm.wps.theme.plugin.samples.helloworld.ButtonContainer" >
        <portal:themeExtensionLoop>
                        <td class="wpsToolBar" valign="middle" nowrap>
                                <a class="wpsToolBarLink" href='<portal:themeExtensionItemUrl />' >
                                        <portal:title varname="<%=themeExtension%>"/>
                                </a>
                        </td>
        </portal:themeExtensionLoop>
</portal:themeExtension>

Theme Include extensions

<portal:themeExtension id="com.ibm.wps.theme.plugin.samples.helloworld.PageBar" >
        <portal:themeExtensionLoop>
                        <portal:themeExtensionRenderInclude />
        </portal:themeExtensionLoop>
</portal:themeExtension>

Controlling visibility of an extension point:
public class InvisibleTextItem implements ThemeTextItem
{
        ...
        
        public boolean isActive()
        {
                //perform some logic
                //logic resolves to invisible
                
                return false;
        }
        ...
}
Using a custom context for a theme extension:

A custom context may be used by specifying "context" attribute in the plugin.xml for a theme extension.

        <extension point="com.ibm.portal.theme.plugin.MainContextMenu">
                <item id="AdministrationLink"
                         class="com.ibm.wps.theme.plugin.impl.DefaultThemePageLinkItemImpl"
                         context="com.ibm.portal.theme.samples.PageThemeContext"
                         title="helloworld.title"
                         description="helloworld.description"
                         ordinal="2"
                         contentNode="wps.Administration" / >
        </extension>

      //stores context information about the current portal page
      //for use in the extension
      public class PageThemeContext implements Identifiable
      {
 
          private ObjectID pageID;
 
          public PageThemeContext( HttpServletRequest req, HttpServletResponse resp )
          {   
              //retrieve the pageID in local variable "someID" 
              this.pageID = someID;
          }
 
          public ObjectID getPageID()
          {
              return this.pageID;
          }
 
          //implement Identifiable
          public ObjectID getObjectID()
          {
              return this.pageID;
          }
 
      }
 
Parsing custom markup from the plugin.xml:
public class TestThemeItem implements IThemeItem
{
        ...
        public void setInitializationData( IConfigurationElement arg0, String arg1, Object arg2 ) throws CoreException
        {
                if ( element == null || !element.getName().equals( ELEMENT_NAME ) )
                        throw new RuntimeException( "Illegal element!" );
        
                String value = null;
        
                value = element.getAttribute( TITLE_ATTRIBUTE );
                if ( value != null) { this.title = value; } 

                value = element.getAttribute( DESCR_ATTRIBUTE );
                if ( value != null) { this.description = value; } 

                value = element.getAttribute( TOOLTIP_ATTRIBUTE );
                if ( value != null) { this.tooltip = value; } 

                value = element.getAttribute( ORDINAL_ATTRIBUTE );
                if ( value != null )
                {
                        try 
                        {
                                final int val = Integer.parseInt( value );
                                this.ordinal = val;
                        }
                        catch ( NumberFormatException nfe )
                        {
                                this.ordinal = -1;
                        }
                }
        }
        ...
}