Portal Guide

CHAPTER 5

Working with Portal Themes

This chapter explains how to use portal themes to control the look and feel of an exteNd Director portal application. It contains the following sections:

 
Top of page

About themes

A portal theme is a set of visual characteristics that apply to an entire exteNd Director portal application. Once you set the theme for a portal application, the settings associated with the theme apply globally. These settings can potentially change the appearance of portal pages (both PID pages and JSP pages) and portlets, as well as the appearance of personal, shared, and container pages. Themes provide a simple way to ensure a consistent appearance throughout a portal application.

 
Top of section

Predefined themes

exteNd Director ships with several predefined themes:

These themes are defined in the portal_core_resource.jar.

TIP:   To preview these themes, display the theme tester page by entering the following URL in your browser:

  http://host/project context/portal/pages/ThemeTester.html

 
Top of section

Files associated with themes

A portal theme consists of several files:

File(s)

Description

Theme descriptor file

Describes the theme. This file provides a display name, description, preview image file, and thumbnail image file for the theme.

The theme descriptor file must be named theme.xml. Each theme used by a portal application must have a separate theme.xml file.

See Theme descriptor file.

Theme style sheet

Contains all of the attributes and properties that define the appearance of a theme when it is rendered at display time.

The theme CSS file must be named theme.css. Each theme used by a portal application must have a separate theme.css file.

See Theme style sheet.

Theme image files

Define various images that are used by the theme. These graphics files are stored in a directory called images.

The theme.css and theme.xml files, and the images directory are all stored in a theme folder. The theme folder is a subdirectory of the portal-theme directory within a resource set. The name of the theme folder provides a key for the theme and uniquely identifies the theme.

For example, here is what the directory structure might look like for the BasicBlue theme:

pgThemesResourceDir

For more information    For more information about where files are located in a resource set, see the chapter on using the Resource Set in an exteNd Director application in Developing exteNd Director Applications.

 
Top of section

Custom themes

You can create custom themes using the Portal Themes Wizard in the exteNd Director development environment, as described in the chapter on creating custom themes.

 
Top of page

Theme descriptor file

Each theme in your portal application must have a theme descriptor file called theme.xml. The theme descriptor file specifies the following information for the theme:

Element name

Description

portal-theme

The root node of the portal theme.

display-name

The name used to identify the theme in the user interface of a portal application.

description

The description of the theme.

preview-image

An image showing what the theme will look like at display time. The theme selector displays preview images for each theme, as described in the section on setting the theme for your portal.

The path to this image can be a fully qualified URL or an URL that contains portal replacement strings.

For more information    For more information, see the chapter on portal replacement strings.

thumbnail-image

A smaller image showing what the theme will look like at display time. This image is typically used in user interfaces listing available themes.

The path to this image can be a fully qualified URL or an URL that contains portal replacement strings.

For more information    For more information, see the chapter on portal replacement strings.

Here is the descriptor file for the BasicBlue theme:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE portal-theme PUBLIC "-//SilverStream Software, LLC//DTD Portal Theme 5.0//EN" "portal-theme_5_0.dtd">
  <portal-theme>
    <display-name>Basic Blue</display-name>
    <description>Basic Blue theme, smooth plastic</description>
    <preview-image>$RESOURCE_URL$/portal-theme/BasicBlue/images/preview.gif
    </preview-image>
  <thumbnail-image>$RESOURCE_URL$/portal-theme/BasicBlue/images/thumbnail.gif
    </thumbnail-image>
  </portal-theme>

Each theme that ships with exteNd Director comes with its own theme.xml file, as described in Files associated with themes.

 
Top of section

Creating custom portal themes

See Creating a portal theme.

 
Top of page

Theme style sheet

Each theme in your application must have a style sheet called theme.css. This file is a standard cascading style sheet (CSS) that will work in Netscape 6 and Microsoft Internet Explorer 5 (and higher versions). Each theme that ships with exteNd Director comes with its own theme.css file.

The style sheet defines a set of classes, some for exteNd Director styles and others for Java Portlet 1.0-compliant portlet styles. These styles can be used to alter the display of portal pages—and of the portlets and XForms 1.0-compliant Web forms that appear on portal pages.

You can create your own styles by defining new classes and editing the settings for the predefined exteNd Director styles.

For more information    To locate theme style sheets, see Files associated with themes.

 
Top of section

Standard exteNd Director style classes

Standard exteNd Director style definitions in theme.css files contain an nv- label.

Standard style types

There are several types of exteNd Director style classes, each designated by a unique prefix:

Style class prefix

Style class description

Example

.nv-

Style that can be applied anywhere within a portal page, portlet, or XForms 1.0-compliant Web form (XForm)

.nv-fontSmall {font-size : 9pt;}

HTML tag.nv-

Style that applies to the specified HTML tag

A.nv-Anchor:hover {
  text-decoration : underline;
  color : #3C5279;
}

NOTE:   This style applies to the HTML anchor tag A

.nvi-

Style that applies to XForms

.nvi-link-style:hover {
  text-decoration : underline;
  color : #3B5367;
  background-color : transparent;

Standard style groups

Here is a list of the predefined exteNd Director style definitions, grouped according to the types of display characteristics they alter:

Style group

Description

Classes defined

Fonts

Define font styles that can be applied anywhere in a portal page or portlet. These styles include settings for the font-family and font-style HTML properties.

  • .nv-font

  • .nv-fontExtraSmall

  • .nv-fontSmall

  • .nv-fontMedium

  • .nv-fontLarge

  • .nv-fontExtraLarge

Foreground colors

Define foreground color styles that can be applied anywhere in a portal page or portlet where the color HTML property is valid.

The numbered color styles are ordered from dark to light. The .nv-color1 style defines the darkest color, and the .nv-color10 style defines the lightest color.

  • .nv-color1

  • .nv-color2

  • .nv-color3

  • .nv-color4

  • .nv-color5

  • .nv-color6

  • .nv-color7

  • .nv-color8

  • .nv-color9

  • .nv-color10

Background colors

Define background color styles that can be applied anywhere in a portal page or portlet where the background-color HTML property is valid.

The numbered color styles are ordered from dark to light. The .nv-color1 style defines the darkest color, and the .nv-color10 style defines the lightest color.

  • .nv-backgroundColor1

  • .nv-backgroundColor2

  • .nv-backgroundColor3

  • .nv-backgroundColor4

  • .nv-backgroundColor5

  • .nv-backgroundColor6

  • .nv-backgroundColor7

  • .nv-backgroundColor8

  • .nv-backgroundColor9

  • .nv-backgroundColor10

Border colors

Define border color styles that can be applied anywhere in a portal page or portlet where the border-color HTML property is valid.

The numbered color styles are ordered from dark to light. The .nv-color1 style defines the darkest color, and the .nv-color10 style defines the lightest color.

  • .nv-borderColor1

  • .nv-borderColor2

  • .nv-borderColor3

  • .nv-borderColor4

  • .nv-borderColor5

  • .nv-borderColor6

  • .nv-borderColor7

  • .nv-borderColor8

  • .nv-borderColor9

  • .nv-borderColor10

Page-level styles

Define font-family, color, background, and background-color settings for the BODY tag.

  • BODY

Paragraph-level styles

Define font-size, font-weight, and color settings for the P tag.

  • .nv-paragraphTextBody

  • .nv-paragraphTextHeader

Table-level styles

Define settings for the TABLE tag.

  • .nv-table

  • .nv-table-header

  • .nv-table-row-even

  • .nv-table-row-odd

Form styles

Define font-size, font-weight, and color settings for form fields, labels, and buttons.

  • nv-formFieldLabel

  • nv-formField

  • nv-formButton

Anchor styles

Define text-decoration and color settings for the A tag. These settings include pseudo-classes that apply to the various user states associated with the A tag.

  • A.nv-Anchor, A.nv-Anchor:active, A.nv-Anchor:link, A.nv-Anchor:visited

  • A.nv-Anchor:hover

exteNd Director Portlet styles

Define various settings associated with the decoration of portlets. You will not ordinarily need to use these styles when developing custom portlets.

  • .nv-componentContainer

  • .nv-titleBarContainer

  • .nv-titleBarBorderLeft

  • .nv-titleBarContentLeft

  • .nv-titleBarContentRight

  • .nv-titleBarBorderRight

  • .nv-bodyContainer

  • .nv-bodyBorderLeft

  • .nv-bodyBorderRight

  • .nv-footerContainer

  • .nv-footerBorderLeft

  • .nv-footerContentLeft

  • .nv-footerContentRight

  • .nv-footerBorderRight

  • A.nv-titlebar-link

  • A.nv-titlebar-link:active, A.nv-titlebar-link:link, A.nv-titlebar-link:visited

  • A.nv-titlebar-link:hover

 
Top of section

Java Portlet 1.0-compliant portlet style definitions

exteNd Director also supports standard CSS classes defined by the Java Portlet 1.0 specification.

These classes are defined with the prefix .portlet, as in this example:

  .portlet-font {
    font-family : Verdana, Arial, Helvetica, sans-serif;
    font-size : 10pt;
  }

For more information    For a list and description of each style definition, see CSS Style Definitions in the Java Portlet 1.0 specification.

The styles defined for portlets give the theme developer a great deal of control over the runtime display of portlets on a page.

For more information    For details on using the portlet styles to theme-enable a portlet, see Creating portlets that are theme-enabled.

 
Top of section

Commenting out properties in styles

By convention, each of the standard exteNd Director style classes specifies values for a common set of HTML properties. However, a class definition need not specify values for all of the possible HTML properties normally associated with the class.

Some of the standard classes for the installed themes use a non-standard prefix to comment out certain property settings. When the browser sees a prefix that it does not recognize, it simply ignores the property. The following example uses a prefix x- to comment out the visibility property of the footer container style:

  .nv-footerContainer {
  	   x-visibility : hidden;
  	   font-size:2pt;
  	   height:16px;
  	   width : 100%;
  }

 
Top of section

Creating a custom theme CSS file

See Creating a theme CSS file.

 
Top of page

Theme image files

A theme can include preview and thumbnail images, which give the user an idea what the theme will look like. A theme can also include images that actually appear when the theme is displayed at runtime. These can include background and foreground images, as well as theme option images, which control the appearance of portal options.

 
Top of section

Theme preview image file

The theme preview image file is typically a screen shot showing what a theme looks like at display time. Here is the preview image file for the BlackNBlue theme:

preview

The size of the preview image should be 320x320.

 
Top of section

Theme thumbnail image file

The thumbnail image file is a smaller image that shows what a theme looks like. Here is the thumbnail image for the BlackNBlue theme:

thumbnail

This image is typically used to list available themes in a user interface. The size of this preview image should be 45x45.

 
Top of section

Theme option image files

Themes can alter the appearance of portal options. For example, suppose a portlet title bar provides buttons to allow the user to edit, minimize, or restore the portlet. You can associate several images with each button so that you can change the button image in response to user events. A theme can alter the image for each user event, giving a consistent look when the user changes the theme.

Each theme can supply a unique set of images for the various events associated with a portal option. However, the file names for these images should be the same in each portal theme. By using a consistent naming convention across themes, you ensure that each user event will have an image to display regardless of which theme has been selected.

For example, you can create an image called edit_onmouseover.gif to handle the edit user event for the Edit option associated with portlet Edit mode. In this case each theme supported by the application should include a file with the same name so that the onmouseover event always has an image to display.

 
Top of page

Creating pages that are theme-enabled

Portal pages can provide support for themes. To allow a PID or JSP page to alter its appearance when a user selects a new theme, you need to make some changes to the source for the page.

To create a page that is theme-enabled, you need to:

 
Top of section

Including the CSS link in a JSP page

To include a <link> tag in the head section of a JSP page that references the currently selected theme, you need to use the getThemeLink tag.

Here's an example that shows how this is done:

  <html>
  <head>
  <title>My Theme-Enabled Page</title>
  
  <%@ taglib uri="/portal" prefix="ep" %>
  <ep:getThemeLink />
  </head>
  ...

The getThemeLink tag causes a <link> tag to be added to the generated HTML for the page. The <link> tag includes a path to the CSS file for the theme. The theme folder in the path is set to the selected theme. For example, when the user selects the BasicBlue theme, the <link> tag looks something like this:

  <html>
  <head>
  <title>My Theme-Enabled Page</title>
  <lnk rel=`stylesheet' type="text/css" href=`http://localhost/Director/MyEar/Portal/main/resource/portal-theme/BasicBlue/theme.css'/>
  </head>
  ...

 
Top of section

Including the CSS link in a PID page

To include a <link> tag in the head section of a PID page that references the currently selected theme, you need to use the s3-component tag to add the PortalUrlHelper portlet to the page. The argument to the PortalUrlHelper portlet includes the syntax for the <link> tag.

Here's an example that illustrates how this is done:

  <html>
  <head>
  <title>My Theme-Enabled Page</title>
  <s3-component id="PortalUrlHelper" instance="Helper" SUBST_STRING="<link rel='stylesheet' type='text/css' href='$THEME_URL$/theme.css'/>"/>
  </head>
  ...

The PortalUrlHelper portlet causes a <link> tag to be added to the generated HTML for the page. The <link> tag includes a path to the CSS file for the theme. The theme folder in the path is set to the selected theme. For example, when the user selects the BasicBlue theme, the <link> tag looks something like this:

  <html>
  <head>
  <title>My Theme-Enabled Page</title>
  <lnk rel=`stylesheet' type="text/css" href=`http://localhost/Director/MyEar/Portal/main/resource/portal-theme/BasicBlue/theme.css'/>
  </head>
  ...

 
Top of page

Creating portlets that are theme-enabled

A portlet can use most of the style definitions in the theme.css file. For example, an HTML portlet might use one or more font or color styles to alter the appearance of text or controls. In the example shown below, the HTML table generated by a portlet uses a theme-specific font style. It also uses two numbered color styles to alternate the color of rows:

  <table class="nv-fontExtraSmall" width="99%" border="0" cellspacing="0" cellpadding="1">
  
   <tr class="nv-table-row-even"> 
    <td width="40%">&nbsp;Bill Lumbergh</td>
    <td width="40%">781-555-1171</td>
    <td width="20%"><div align="center"></div>
    </td>
   </tr>
   <tr class="nv-table-row-odd"> 
    <td>&nbsp;Peter Gibbons </td>
    <td>781-555-3457</td>
    <td><div align="center"></div>
    </td>
   </tr>
   <tr class="nv-table-row-even"> 
    <td>&nbsp;Michael Bolton </td>
    <td>781-555-3566</td>
    <td><div align="center"></div>
    </td>
   </tr>
   <tr class="nv-table-row-odd"> 
    <td>&nbsp;Milton Waddams </td>
    <td>781-555-3442</td>
    <td><div align="center"></div>
    </td>
   </tr>
   <tr class="nv-table-row-even"> 
    <td>&nbsp;Samir Nayeenanajar </td>
    <td>781-555-3316</td>
    <td><div align="center"></div>
    </td>
   </tr>
  </table>

An HTML portlet could use string concatenation techniques in the doView() method to generate this data. For an XML portlet, the styles would be specified in an XSL style sheet, as shown below:

  <!-- Alternate the color of each row in the table -->
  <xsl:template match="employee">
   <xsl:choose>
    <xsl:when test="position() mod 2 = 1">
     <xsl:call-template name="employee_data">
     <xsl:with-param name="StyleClass">nv-backgroundColor3</xsl:with-param>
     </xsl:call-template>	 	 
    </xsl:when>
  
   <xsl:otherwise>
     <xsl:call-template name="employee_data">
      <xsl:with-param name="StyleClass">nv-backgroundColor5
        </xsl:with-param>
      </xsl:call-template>
   </xsl:otherwise>
   </xsl:choose>
  </xsl:template>

 
Top of section

How the default decorator class renders a portlet

The runtime display of a portlet is controlled by a portal decorator. A portal decorator is a Java class that builds the various display elements for a portlets on a page. exteNd Director provides a default decorator class called EboDefaultPortalDecorator, which is in the com.sssw.portal.core package.

To render the title bar, body, and footer for a portlet, the default decorator generates three separate HTML tables. Each of these tables uses class definitions provided in the theme.css file to ensure that the display is appropriate for the currently selected theme.

The following extract from the source code for EboDefaultPortalDecorator class shows how the standard portlet class definitions are used to render a portlet. Each class name defined in the theme.css file is highlighted in the source code:

  package com.sssw.portal.core;
  
  import com.sssw.portal.api.*;
  
  public class EboDefaultPortalDecorator extends EboComponentDecorator{
  
  
  public String decorateComponentData(EbiPortalContext context, String componentID, String componentData) {
  
    return "<DIV class=nv-componentContainer>"
      + getTitleBarFragment(context)
      + getBodyFragment(context, componentData)
      + getFooterFragment(context)
      + "</DIV>";
   }
  
  
  public String getTitleBarFragment(EbiPortalContext context){
  
    StringBuffer buffer = new StringBuffer("");
  
    // Build the title bar for this component
    // It is a table which consists of 1 row with 4 columns (leftBoder, leftContent, RightContent, rightBorder)
    buffer.append("<table class=\"nv-titleBarContainer\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
    buffer.append("  <tr>\n");
    buffer.append("   <td class=\"nv-titleBarBorderLeft\"></td>\n");
    buffer.append("   <td class=\"nv-titleBarContentLeft\">" +
     getTitleBarContentLeft(context) + "</td>\n");
    buffer.append("   <td class=\"nv-titleBarContentRight\">" +
     getTitleBarContentRight(context) + "</td>\n");
    buffer.append("   <td class=\"nv-titleBarBorderRight\"></td>\n");
    buffer.append("  </tr>\n");
    buffer.append("</table>\n");
  
    return buffer.toString();
  
  }
  
  
  public String getBodyFragment(EbiPortalContext context, String contentFragment){
  
    StringBuffer buffer = new StringBuffer();
  
  
    buffer.append("<table class=\"nv-bodyContainer\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
    buffer.append("  <tr>\n");
    buffer.append("   <td class=\"nv-bodyBorderLeft\"></td>\n");
    buffer.append("   <td>" + contentFragment + "</td>\n");
    buffer.append("   <td class=\"nv-bodyBorderRight\"></td>\n");
    buffer.append("  </tr>\n");
    buffer.append("</table>\n");
  
    return buffer.toString();
  }
  
  
  
  public String getFooterFragment(EbiPortalContext context){
    StringBuffer buffer = new StringBuffer();
  
  
    buffer.append("<table class=\"nv-footerContainer\" border=\"0\"
     cellspacing=\"0\" cellpadding=\"0\">\n");
    buffer.append("  <tr>\n");
    buffer.append("   <td class=\"nv-footerBorderLeft\"></td>\n");
    buffer.append("   <td class=\"nv-footerContentLeft\">" +
     getFooterContentLeft(context) + "</td>\n");
    buffer.append("   <td class=\"nv-footerContentRight\">" +
     getFooterContentRight(context) + "</td>\n");
    buffer.append("   <td class=\"nv-footerBorderRight\"></td>\n");
    buffer.append("  </tr>\n");
    buffer.append("</table>\n");
  
    return buffer.toString();
      }
  ...

 
Top of section

How the CSS file changes the appearance of a portlet

The CSS file for a theme divides the visual display of a portlet into several sections, as shown below:

ThemeComponentNoGraphic

How does this display scheme apply to a real-world example? Consider the Weather Service portlet, displayed here in the Titanium theme:

WeatherService

The following illustration shows how each display section of the Weather Service portlet is rendered in the Titanium theme:

ThemeComponentWithGraphic2

The theme.css file for the Titanium theme specifies background images for most of the display sections for a portlet:

Class

Description

Image

.nv-componentContainer

Component container

None

.nv-titleBarContainer

Title bar container

TitleBarMiddleTitanium

.nv-titleBarBorderLeft

Left border for the title bar

TitleBarLeftTitanium

.nv-titleBarContentLeft

Left content for the title bar

TitleBarContentLeftTitanium

.nv-titleBarBorderRight

Right border for the title bar

TitleBarRightTitanium

.nv-titleBarContentRight

Right content for the title bar

TitleBarMiddleTitanium

.nv-titleBarContainer

Container for the title bar

TitleBarMiddleTitanium

.nv-bodyContainer

Body container

None

.nv-bodyBorderLeft

Left border for the body

BodyLeftTitanium

.nv-bodyBorderRight

Right border for the body

BodyRightTitanium

.nv-footerContainer

Footer container

FooterMiddleTitanium

.nv-footerBorderLeft

Left border for the footer

FooterLeftTitanium

.nv-footerContentLeft

Left content for the footer

FooterMiddleTitanium

.nv-footerContentRight

Right content for the footer

FooterMiddleTitanium

.nv-footerBorderRight

Right border for the footer

FooterRightTitanium

A.nv-titlebar-link

Anchor style for title bar links

None

A.nv-titlebar-link:active, A.nv-titlebar-link:link, A.nv-titlebar-link:visited

Anchor style for title bar links that are in the active, link, or visited state

None

A.nv-titlebar-link:hover

Anchor style for title bar links that are in the hover state

None

 
Top of page

Working with the theme API

The exteNd Director API provides two interfaces for working with themes:

EbiThemeManager provides methods for accessing EbiThemeInfo objects. EbiThemeInfo provides methods for retrieving various kinds of information about a theme, including its display name and description. The EbiThemeInfo interface also provides access to the URIs for a theme's preview and thumbnail images.

To access an EbiThemeManager object, you need to use the getThemeManager() method on the EboFactory class for the Portal subsystem.



Copyright © 2004 Novell, Inc. All rights reserved. Copyright © 1997, 1998, 1999, 2000, 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.  more ...