Layout of WebSphere portal page

本文介绍了WebSphere Portal中门户页面的组成结构,包括主题、屏幕和皮肤的作用及配置方法。详细解释了如何通过定制主题来调整页面布局,并提供了关于主题策略、屏幕选择和皮肤应用的相关信息。

Layout of the portal page

Before customizing your portal site, understand the underlying structure of the portal.

The portal page is composed of JSPs and statically included JSP fragments (JSPFs) for screens , themes , and skins that are typically created by the Web designer of the portal. These JSPs reside in the corresponding /screens , /themes , /skins directories under :

Within this location, subdirectories for markup, locale, and client types are used to support portal aggregation.

themes
provide the navigation, appearance, and layout of the portal, including colors, fonts, and images outside of the portlet content area (Home screen).
screens
the area of the portal that typically displays portlets (Home screen), but can also display other content in its place, for example, a login form or error message. Screens are selected from navigation icons in the theme.
skins
represent the border rendering around components, such as row containers, column containers, or portlets. Skins are installed independently from themes. However, the administrator can set a default skin for a theme.

The starting place for building the portal page is Default.jsp in the /themes directory. The screen and skin are called by their corresponding tags from the portal-core tag library: the screen is called by the <portal-core:screenRender/> tag, while the skin is called by the <portal-core:pageRender/> tag.

The diagram below illustrates how themes, screens, and skins are used in the portal.

Themes

You can add your own elements to the HTML portal page and rearrange the layout by creating a new theme and changing the layout in Default.jsp and the JSPs that are included. Learn about the order and layout in which the portal page theme is built using the JSPs that are provided after installation. Use this information to learn how to include some of these components as you build your own themes.

For most requests, the portal page is rendered starting with Default.jsp in the /themes directory. The only exception is when the request has been modified by a newWindow="true" parameter. In this case, the page is rendered using Plain.jsp . Plain.jsp is normally used to render portlet help or for portlets that use the iFrame skin.

Theme policy is used to control how a theme is rendered on a page. A policy is created and stored using the XML configuration interface. Once stored, it can be applied to a page either through the XML configuration interface using the page metadata attribute com.ibm.portal.ThemePolicy or through the Properties portlet. Theme policy is inherited so it only needs to be set on a page which requires a different policy than its parent.

Head

Head.jspf provides the necessary header information to correctly render the portal page. This file is used to link the style sheets and client-side scripts as well as set the page title and the text direction.

Banner

Banner.jspf includes the user interface elements across the top of the page. This includes the following:
  • Top level links - a listing of the top level nodes directly under Content Root which includes a "More..." menu if the number of links exceeds a certain value.
  • Breadcrumb trail (banner_crumbtrail.jspf ) - the current page selection path to the current page.
  • Search controls (banner_searchControl.jspf ) - a search form to various search scopes.
  • Toolbar actions (banner_toolbar.jspf ) - a set of buttons to access various flyout panels and actions.

Top navigation

topNav.jspf creates one or more rows of navigation tabs. Theme policy values control whether the top navigation is rendered and how many rows are rendered.

Side navigation

sideNav.jspf creates an expandable tree of navigation nodes. The side navigation renders any navigation levels that have not been rendered by the top navigation.

Footers

footer.jspf renders a section across the bottom of the portal page. By default, this includes quick links to commonly accessed areas of portal. The links rendered are internal URLs which are children of the portal page with the unique name ibm.portal.Quick Links .

Palettes

Flyout.jspf contains a hidden document division (<div/> ) which is used by actions in the banner's toolbar to display content which is dynamically displayed and hidden as needed.

Context menus

The context menus in the Portal theme and IBM skin (the defaults) are loaded asynchronously. The contents of the menu are controlled by a JSP in the /themes/html/Portal directory. The following information describes which JSP is used to control specific menus:
Table 1. Context menus and controlling JSPs
MenuControlling JSP
More menumoreMenu.jsp
Page menu (on selected page)pageContextMenu.jsp
Portlet menuportletContextMenu.jsp
Note: The page and portlet context menu icon can only be seen if you hover over the upper right corner of the portlet and page title.
The URLs to these JSPs are created using the <portal-navigation:url themeTemplate="mainMenu"/> where the themeTemplate attribute is the name of the JSP to load (without the file extension). As a result, it is important to note that any URL created in one of these controlling JSPs must have the theme template reset, either by using the themeTemplate attribute on the urlGeneration tag or by using the available public APIs.
Note: Context menus are disabled until a page fully loads. In more detail, the context menus on the page (for example, Main menu, Page menu, and any portlet menus in the default Portal theme) are initially disabled and then re-enabled in an onload handler. This event occurs because clicking on a context menu before the page is completely loaded (that is, when portlet JSPs are still compiling) causes an error and the menu does not load.

Drag and drop feature

The drag-and-drop feature lets you quickly change the placement of individual portlets using your skins. The drag-and-drop feature lets you move a custom portlet from its current position by dropping it to another position on a page. This lets you quickly change the arrangement of your custom portlets on a page.

Theme policy

Theme policies control how a theme renders for a particular page. The attributes of the theme policy assigned to the current page are consumed by the theme JSPs to control what gets rendered, as well as how it is rendered.

Screens

The selected screen is rendered by the <portal-core:screenRender/> tag.

Default themes

For HTML, the following themes are provided by WebSphere Portal .
  • Portal theme - This is the default theme for WebSphere Portal and is a full-featured theme that demonstrates all available theme functionality.
  • Minimal theme - This theme, located in the root themes/html directory, is a minimal "safe" fallback that includes only the minimum required to render a functioning portal. It does not include all of the functionality available in WebSphere Portal , such as drag and drop and context menus. This theme is not intended for normal use, and is not explicitly defined as a theme by name, but rather only exists as a fallback should there be a problem with the main portal theme, and also as an example of a minimal theme.
  • Portal Web 2 theme - This theme showcases Web 2.0 functionality in WebSphere Portal . Taking full advantage of AJAX and JavaScript, this theme features a rich user experience on the client with partial page updates and inline portlet editing.
Note: If the Portal theme directory is either deleted or renamed, the portal resource loader uses the themes/html/Default.jsp . In this case, you should also use the fallback skin. To do this, rename the skins directory. For example, the skins/html/IBM directory should be renamed skins/html/IBM1 . If you have a broken theme, you can rename the theme and skin directories which are causing the problem to get to a working minimal theme.

<portal-theme:cacheProxyUrl/> JSP tag

The switch to using JSPs for style sheets provides a great advantage in the reduction of the number of files that must be maintained or generated when a style sheet is updated. However, a performance concern is introduced in that the output of the compiled JSPs needs to be cached to avoid having to be generated on each request. WebSphere Portal provides the <portal-theme:cacheProxyUrl/> JSP tag to solve this problem.

The <portal-theme:cacheProxyUrl/> tag creates a URL to the caching proxy servlet. The URL created is fully cacheable and includes information about the requesting client. The CC/PP client profile is used for gathering information about the client for the URL. The purpose of this tag is to link .CSS files into the JSP.
Note: For security reasons, the cache proxy servlet will only serve URLs pointing to resources located in the themes, skins, and screens directories. This makes all resources underneath these directories public. Also, any URLs containing the ".." characters will not be served.

Theme policies

Learn about theme policy, theme policy attributes, and the theme policies available with WebSphere Portal . Learn about setting a theme policy on a page using the XML configuration interface, using theme policy in a JSP, creating your own theme policy, and updating, exporting, and deleting a theme policy.

Theme policy is used to control how a theme is rendered on a page. A policy is created and stored using the XML configuration interface. Once stored, it can be applied to a page either through the XML configuration interface using the page metadata attribute com.ibm.portal.ThemePolicy or the Properties portlet. Theme policy is inherited so it only needs to be set on a page which requires a different policy than its parent.

This topic provides the following information on theme policies:

Theme policy attributes

A theme policy is made up of several attributes. Each attribute controls one aspect of the theme. For example, the Boolean renderBreadCrumb attribute controls whether the bread crumb will be displayed while the breadCrumbMaxLevels attribute controls the number of steps listed in the bread crumb when it is displayed.

The following table provides type and functional information on all available theme policy attributes. For a full listing, it is recommended that you export the theme policy. See the exporting a theme policy section of this topic for more information.
Table 1. Theme policy attributes
AttributeTypeFunction
renderMainMenuBooleanIf true, the main menu is rendered
renderTopNavigationBooleanIf true, top navigation is rendered
renderMainMenuActionsBooleanIf true, the main menu actions are rendered
renderSelfCareBooleanIf true, Selfcare is rendered
renderBreadCrumbTrailBooleanIf true, the bread crumb trail is rendered
renderSearchBooleanIf true, search is rendered
renderToolBarBooleanIf true, the tool bar is rendered
renderContentPaletteBooleanIf true, the portlet palette is rendered
renderPeoplePaletteBooleanIf true, the people palette is rendered
renderContextMenus BooleanIf true, context menus are render
renderSideNavigation BooleanIf true, side navigation is rendered
renderTaskBarBooleanIf true, the task bar is rendered
renderFavoritesBooleanIf true, favorites is rendered
renderExtensions BooleanIf true, extensions are rendered
renderBannerTitleGraphicBooleanIf true, the banner title graphic is rendered as long as one exists
renderPortletFragmentIDAnchorBooleanUsed to determine if the user is on a palette page
renderBannerTitleBooleanIf true, the banner title is rendered as long as one exists
breadCrumbMaxLevelsIntegerIndicates the number of steps listed in the bread crumb trail
breadCrumbStartLevelIntegerIndicates which level to start the bread crumb trail
rootNavigationStartLevelIntegerIndicates the start level for root navigation
rootNavigationStopLevelIntegerIndicates the stop level for root navigation
topNavigationNumRows IntegerIndicates the number of rows to render for top navigation
topNavigationStartLevelIntegerIndicates the start level for top navigation
topNavigationStopLevelIntegerIndicates the stop level for top navigation
sideNavigationStartLevelIntegerIndicates the start level for side navigation
isCustomizableBooleanIf true, the policy can be edited in the Theme Customizer portlet.
isDeletableBooleanIf true, the policy can be deleted in the Theme Customizer portlet.
Note: xmlaccess ignores this attribute.
colorPaletteString

If specified, the value in this attribute is the name of the color palette.

The search order for the name of the color palette used on the page is:
  1. the value of the colorPalette page meta data attribute
  2. the value of the colorPalette attribute in the policy assigned to the current page
  3. the string "default"

The name of the color palette must be the name of a properties file provided in the theme without the .properties extension.

colorPalettePropertiesStringColor Palette information. This is a stored java.util.Properties object created by the Theme Customizer portlet. The theme first loads the color palette for the page and then overwrites those values with any that may be present in this attribute.
graphicFilesMimeDataStringIf specified, graphic files uploaded through the Theme Customizer portlet. This attribute is a standard multipart/mixed MIME text stream containing attachments encoded with Base64 encoding.
styleVersionIntegerThe version number of the policy. This value is incremented each time the Theme Customizer portlet saves the policy so updates to the policy can be loaded without clearing the browser cache.
bannerTitleTextString

Indicates the text that is to be displayed as the title in the banner and browser title bar.

If this value is empty, the bannerTitleTextResourceBundle and bannerTitleTextResourceKey attributes are used to determine the title text.

bannerTitleTextResourceBundleStringIndicates the resource bundle containing the title text.
bannerTitleTextResourceKeyStringIndicates the resource bundle key that is to be used to locate the title
bannerTitleGraphicString

Indicates the URI of the title graphic to be displayed in the banner. This value is passed on the uri attribute of the portal-resolver:url tag.

Values created by the Theme Customizer portlet are of the form: "themeGraphic:policy:filePath:xxx " where xxx is the name of the attachment stored in the graphicFilesMimeData attribute.

renderBannerQuickLinksBooleanIf true, banner quick links are rendered
renderHelpLinkBooleanIf true, the help link is rendered
renderQuickLinksShelfBooleanIf true, the quick links shelf is rendered
quickLinksShelfStyleInteger

Style attributes for the quick links shelf. This is a bitmask field. If bit 1 is turned on, the quick links shelf default state is expanded. If bit 2 is turned on, the expand/collapse link is hidden.

As such, the following values are supported:
  • 0 = default shelf state is collapsed and the expand/collapse link is shown
  • 1 = default shelf state is expanded and the expand/collapse link is shown
  • 2 = default shelf state is collapsed and the expand/collapse link is hidden
  • 3 = default shelf state is expanded and the expand/collapse link is hidden
Numbers other than 0, 1, 2, or 3 are reserved for future use.
renderApplicationNameBooleanIf true, the application name is rendered
renderCustomizeThemeLinkBooleanIf true, the theme customizer link is rendered

Provided theme policies

WebSphere Portal provides ten policies that may be used without alteration. The following information provides lists of each policy along with the corresponding attributes, values, and types.

Note: The Federation, SingleTopNavLevel2, and Palette theme policies should not be modified.
Default
  • renderMainMenu=TRUE
  • renderTopNavigation=TRUE
  • renderMainMenuActions=TRUE
  • renderSelfCare=TRUE
  • renderBreadCrumbTrail=FALSE
  • renderSearch=TRUE
  • renderToolBar=TRUE
  • renderContentPalette=TRUE
  • renderPeoplePalette=TRUE
  • renderContextMenus=TRUE
  • renderSideNavigation=TRUE
  • renderTaskBar=TRUE
  • renderFavorites=TRUE
  • renderExtensions=TRUE
  • renderBannerTitleGraphic=TRUE
  • renderBannerTitle=TRUE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels=5
  • breadCrumbStartLevel=1
  • rootNavigationStartLevel=1
  • rootNavigationStopLevel=1
  • topNavigationNumRows=1
  • topNavigationStartLevel=2
  • topNavigationStopLevel=2
  • sideNavigationStartLevel=3
  • isCustomizable=FALSE
  • isDeletable=TRUE
  • colorPalette=""
  • colorPaletteProperties=""
  • graphicFilesMimeData=""
  • styleVersion=1
  • bannerTitleText=""
  • bannerTitleTextResourceBundle=""
  • bannerTitleTextResourceKey=""
  • bannerTitleTextResourceKey=""
  • bannerTitleGraphic=""
  • renderBannerQuickLinks=TRUE
  • renderHelpLink=TRUE
  • renderQuickLinksShelf =FALSE
  • quickLinksShelfStyle=1
  • renderApplicationName=TRUE
  • renderCustomizeThemeLink=FALSE
SingleTopNav
  • renderMainMenu = TRUE
  • renderTopNavigation = TRUE
  • renderMainMenuActions= TRUE
  • renderSelfCare = TRUE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = TRUE
  • renderToolBar = TRUE
  • renderContentPalette = TRUE
  • renderPeoplePalette = TRUE
  • renderContextMenus = TRUE
  • renderSideNavigation = TRUE
  • renderTaskBar = TRUE
  • renderFavorites = TRUE
  • renderExtensions = TRUE
  • renderBannerTitleGraphic = TRUE
  • renderBannerTitle=TRUE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels = 5
  • breadCrumbStartLevel = 1
  • rootNavigationStartLevel = 1
  • rootNavigationStopLevel = 1
  • topNavigationNumRows = 1
  • topNavigationStartLevel = 2
  • topNavigationStopLevel = 2
  • sideNavigationStartLevel = 3
SingleTopNavMinimal
  • renderMainMenu = TRUE
  • renderTopNavigation = TRUE
  • renderMainMenuActions = FALSE
  • renderSelfCare = FALSE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = FALSE
  • renderToolBar = FALSE
  • renderContentPalette = FALSE
  • renderPeoplePalette = FALSE
  • renderContextMenus = FALSE
  • renderSideNavigation = TRUE
  • renderTaskBar = FALSE
  • renderFavorites = FALSE
  • renderExtensions = FALSE
  • renderBannerTitleGraphic = FALSE
  • renderBannerTitle = FALSE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels = 0
  • breadCrumbStartLevel = 0
  • rootNavigationStartLevel = 1
  • rootNavigationStopLevel = 1
  • topNavigationNumRows = 1
  • topNavigationStartLevel = 2
  • topNavigationStopLevel = 2
  • sideNavigationStartLevel = 3
DoubleTopNav
  • renderMainMenu = TRUE
  • renderTopNavigation = TRUE
  • renderMainMenuActions = TRUE
  • renderSelfCare = TRUE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = TRUE
  • renderToolBar = TRUE
  • renderContentPalette = TRUE
  • renderPeoplePalette = TRUE
  • renderContextMenus = TRUE
  • renderSideNavigation = TRUE
  • renderTaskBar = TRUE
  • renderFavorites = TRUE
  • renderExtensions = TRUE
  • renderBannerTitleGraphic = TRUE
  • renderBannerTitle = TRUE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels = 5
  • breadCrumbStartLevel = 1
  • rootNavigationStartLevel = 1
  • rootNavigationStopLevel = 1
  • topNavigationNumRows = 2
  • topNavigationStartLevel = 2
  • topNavigationStopLevel = 3
  • sideNavigationStartLevel = 4
DoubleTopNavMinimal
  • renderMainMenu = TRUE
  • renderTopNavigation= TRUE
  • renderMainMenuActions = FALSE
  • renderSelfCare = FALSE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = FALSE
  • renderToolBar = FALSE
  • renderContentPalette = FALSE
  • renderPeoplePalette = FALSE
  • renderContextMenus = FALSE
  • renderSideNavigation = TRUE
  • renderTaskBar = FALSE
  • renderFavorites = FALSE
  • renderExtensions = FALSE
  • renderBannerTitleGraphic = FALSE
  • renderBannerTitle = FALSE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels = 0
  • breadCrumbStartLevel = 0
  • rootNavigationStartLevel = 1
  • rootNavigationStopLevel = 1
  • topNavigationNumRows = 2
  • topNavigationStartLevel = 2
  • topNavigationStopLevel = 3
  • sideNavigationStartLevel = 4
SideNavOnly
  • renderMainMenu = TRUE
  • renderTopNavigation = FALSE
  • renderMainMenuActions = TRUE
  • renderSelfCare = TRUE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = TRUE
  • renderToolBar = TRUE
  • renderContentPalette = TRUE
  • renderPeoplePalette = TRUE
  • renderContextMenus = TRUE
  • renderSideNavigation = TRUE
  • renderTaskBar = TRUE
  • renderFavorites = TRUE
  • renderExtensions = TRUE
  • renderBannerTitleGraphic = TRUE
  • renderBannerTitle = TRUE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels = 5
  • breadCrumbStartLevel = 1
  • rootNavigationStartLevel = 1
  • rootNavigationStopLevel = 1
  • topNavigationNumRows = 0
  • topNavigationStartLevel = 0
  • topNavigationStopLevel = 0
  • sideNavigationStartLevel = 2
SideNavOnlyMinimal
  • renderMainMenu = TRUE
  • renderTopNavigation = FALSE
  • renderMainMenuActions = FALSE
  • renderSelfCare = FALSE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = FALSE
  • renderToolBar = FALSE
  • renderContentPalette = FALSE
  • renderPeoplePalette = FALSE
  • renderContextMenus = FALSE
  • renderSideNavigation =TRUE
  • renderTaskBar = FALSE
  • renderFavorites = FALSE
  • renderExtensions = FALSE
  • renderBannerTitleGraphic = FALSE
  • renderBannerTitle = FALSE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels = 5
  • breadCrumbStartLevel = 0
  • rootNavigationStartLevel = 1
  • rootNavigationStopLevel = 1
  • topNavigationNumRows = 0
  • topNavigationStartLevel = 0
  • topNavigationStopLevel = 0
  • sideNavigationStartLevel = 2
NoTheme
  • renderMainMenu = FALSE
  • renderTopNavigation = FALSE
  • renderMainMenuActions = FALSE
  • renderSelfCare = FALSE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = FALSE
  • renderToolBar = FALSE
  • renderContentPalette = FALSE
  • renderPeoplePalette = FALSE
  • renderContextMenus = FALSE
  • renderSideNavigation = FALSE
  • renderTaskBar = FALSE
  • renderFavorites = FALSE
  • renderExtensions = FALSE
  • renderBannerTitleGraphic = FALSE
  • renderBannerTitle = FALSE
  • renderPortletFragmentIDAnchor=FALSE
  • breadCrumbMaxLevels = 0
  • breadCrumbStartLevel = 0
  • rootNavigationStartLevel = 0
  • rootNavigationStopLevel = 0
  • topNavigationNumRows = 0
  • topNavigationStartLevel = 0
  • topNavigationStopLevel = 0
  • sideNavigationStartLevel = 0
Federation
Note: The Federation theme policy cannot be applied to a page either through the XML configuration interface using the page attribute com.ibm.portal.ThemePolicy or the Properties portlet.
  • renderMainMenu = FALSE
  • renderTopNavigation = FALSE
  • renderMainMenuActions = FALSE
  • renderSelfCare = FALSE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = TRUE
  • renderToolBar = TRUE
  • renderContentPalette = TRUE
  • renderPeoplePalette = TRUE
  • renderContextMenus = FALSE
  • renderSideNavigation = FALSE
  • renderTaskBar = FALSE
  • renderFavorites = FALSE
  • renderExtensions = FALSE
  • renderBannerTitleGraphic = FALSE
  • renderBannerTitle = FALSE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels = 0
  • breadCrumbStartLevel = 0
  • rootNavigationStartLevel = 0
  • rootNavigationStopLevel = 0
  • topNavigationNumRows = 0
  • topNavigationStartLevel = 0
  • topNavigationStopLevel = 0
  • sideNavigationStartLevel = 0
SingleTopNavLevel2
  • renderMainMenu = TRUE
  • renderTopNavigation = TRUE
  • renderMainMenuActions= TRUE
  • renderSelfCare = TRUE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = TRUE
  • renderToolBar = TRUE
  • renderContentPalette = TRUE
  • renderPeoplePalette = TRUE
  • renderContextMenus = TRUE
  • renderSideNavigation = TRUE
  • renderTaskBar = TRUE
  • renderFavorites = TRUE
  • renderExtensions = TRUE
  • renderBannerTitleGraphic = TRUE
  • renderBannerTitle = TRUE
  • renderPortletFragmentIDAnchor=TRUE
  • breadCrumbMaxLevels = 5
  • breadCrumbStartLevel = 2
  • rootNavigationStartLevel = 1
  • rootNavigationStopLevel = 1
  • topNavigationNumRows = 1
  • topNavigationStartLevel = 2
  • topNavigationStopLevel = 2
  • sideNavigationStartLevel = 3
Palette
  • renderMainMenu = TRUE
  • renderTopNavigation = TRUE
  • renderMainMenuActions= TRUE
  • renderSelfCare = TRUE
  • renderBreadCrumbTrail = FALSE
  • renderSearch = TRUE
  • renderToolBar = TRUE
  • renderContentPalette = TRUE
  • renderPeoplePalette = TRUE
  • renderContextMenus = TRUE
  • renderSideNavigation = TRUE
  • renderTaskBar = TRUE
  • renderFavorites = TRUE
  • renderExtensions = TRUE
  • renderBannerTitleGraphic=TRUE
  • renderBannerTitle=TRUE
  • renderPortletFragmentIDAnchor=FALSE
  • breadCrumbMaxLevels = 5
  • breadCrumbStartLevel = 1
  • rootNavigationStartLevel = 1
  • rootNavigationStopLevel = 1
  • topNavigationNumRows = 1
  • topNavigationStartLevel = 2
  • topNavigationStopLevel = 2
  • sideNavigationStartLevel = 3

Custom theme attributes

In addition to the attributes in each policy above, you can add an attribute to the theme policies and then use it in your JSP or JSPF. The following code samples show how the custom attribute renderTestAttribute is added to theme policy and how it is accessed in a JSP or JSPF.

The main theme policy must have the attribute and a lock attribute. This is added to the root theme policy as follows:
<policyValue
Name="renderTestAttribute"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderTestAttributeLock"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>false</value>
</policyValue>

The policy value sets consisting of attributes and their values can be nested. Child attributes can either inherit or override the values from the parent attribute. When you specify the value of a lock attribute corresponding to a policy attribute as true, you lock the policy node. In this case, the child attributes necessarily inherit the values from parent attributes and cannot override these values.

Use the following code to add the attribute to each theme policy that requires a value different from the root theme policy:
<policyValue
Name="renderTestAttribute"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>false</value>
</policyValue>
Since this is a Boolean, the value would be set to true or false.
Use the following code to access the attribute in a JSP or JSPF:
<% boolean isTestAttribute = themePolicy.getValueAsBoolean("renderTestAttribute", false); 
if(isTestAttribute){%>
<p> Display this paragrah if renderTestAttribute is true. </p>
<%}%>

In the above example, if the value of renderTestAttribute is true, the paragraph is displayed. themePolicy is defined in the Using theme policy in a JSP section of this topic.

There are three accessor methods:
  • getValueAsBoolean(String key, boolean defaultValue);
  • getValueAsInt(String key, int defaultValue);
  • getValueAsString(String key, String defaultValue);
where key is the name of the attribute and defaultValue is the value that will be used if the attribute value can not be retrieved from the theme policy.

Setting theme policy on a page using the XML configuration interface

Theme Policy can be applied to a page through the XML configuration interface using the page metadata attribute com.ibm.portal.ThemePolicy . The following provides an example of an XML script that sets the page metadata for the theme policy for the page ThemePolicyPageTest :

<request type="update" create-oids="true" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd">
<portal action="locate">
<content-node action="update" ordinal="last"
uniquename="ibm.portal.ThemePolicyPageTest" content-parentref="Content.Root"
active="true" allportletsallowed="false" create-type="explicit"
objectid="wp.theme.policytestpage" type="page">
<supported-markup markup="html" update="set"/>
<!--@LocaleData_1@-->
<parameter name="com.ibm.portal.ThemePolicy" type="string"
update="set">theme/SingleTopNavMinimal</parameter>
</content-node>

</portal>
</request>

Using theme policy in a JSP

You can also use a theme policy directly in a JSP. Use the following code to do this:

<themepolicy:initthemepolicy/>
<jsp:useBean id="themePolicy"
class="com.ibm.portal.theme.policy.ThemePolicyBean" scope="page"/>
<% themePolicy.setValuesMap(portalThemePolicyMap);%>

In this code example, the theme bean is initialized which wrappers the theme policy attributes.

To use an attribute in the JSP, reference it with the following syntax: ${themePolicy.attribute) where the attribute would be, for example, renderSideNavigation . The following code tests renderSideNavigation . If it is TRUE, the following code is executed:

<c-rt:if test = "${themePolicy.renderSideNavigation}">
<!-- following code -->
<….>
<….>
</c-rt:if>

The following code example sets startLevel to the value of the theme policy attribute sideNavigationStartLevel :

<portal:navigation  startLevel="${themePolicy.sideNavigationStartLevel}"

Creating your own theme policy

The following code example addThemePolicyNode.xml provides an example of how to create and add a new theme policy. This XML file would then be updated to reflect the location and name of the file which contains the theme policy XML definition.

<?xml version="1.0" encoding="UTF-8"?>
<request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"
create-oids="true" type="update"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<portal action="locate">
<policy-node action="update" label="WebPage" type="" path="">
<url>file:///c:/temp/addTestThemePolicyNode.xml</url>
</policy-node>
</portal>
</request>
Use the XML configuration interface to run addThemePolicyNode.xml which references the TestThemePolicy definition file addTestThemePolicyNode.xml listed as follows. This file represents the theme policy XML definition.
Note: It is important that the following attributes in this file be set as follows:
  • Type attribute should be set to "theme"
  • PathType attribute should be set to "/theme"
  • PznType and Title attributes should have the same value.
<?xml version="1.0" encoding="UTF-8"?>
<!--

Licensed Materials - Property of IBM, 5724-E76, 5655-R17,
(C) Copyright IBM Corp. 2006 - All Rights reserved.

-->
<policyList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="Policy.xsd">
<policy>
<policyValue
Name="Path"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value></value>
</policyValue>
<policyValue
Name="Type"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value>theme</value>
</policyValue>
<policyValue
Name="Description"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value>Test Theme Policy</value>
</policyValue>
<policyValue
Name="Title"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value>TestThemePolicy</value>
</policyValue>
<policyValue
Name="Editor"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value></value>
</policyValue>
<policyValue
Name="NameResKey"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value></value>
</policyValue>
<policyValue
Name="PznRule"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value></value>
</policyValue>
<policyValue
Name="PznType"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value>TestThemePolicy</value>
</policyValue>
<policyValue
Name="Remote"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value></value>
</policyValue>
<policyValue
Name="PathType"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value>/theme</value>
</policyValue>
<policyValue
Name="renderMainMenu"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderTopNavigation"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderMainMenuActions"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderSelfCare"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderBreadCrumbTrail"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>false</value>
</policyValue>
<policyValue
Name="renderSearch"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderToolBar"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderContentPalette"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderPeoplePalette"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderContextMenus"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderSideNavigation"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderTaskBar"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderFavorites"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderExtensions"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderBannerTitleGraphic"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderBannerTitle"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="renderPortletFragmentIDAnchor"
Factory="com.ibm.wps.policy.parse.BooleanFactory">
<value>true</value>
</policyValue>
<policyValue
Name="breadCrumbMaxLevels"
Factory="com.ibm.wps.policy.parse.IntegerFactory">
<value>5</value>
</policyValue>
<policyValue
Name="breadCrumbStartLevel"
Factory="com.ibm.wps.policy.parse.IntegerFactory">
<value>1</value>
</policyValue>
<policyValue
Name="rootNavigationStartLevel"
Factory="com.ibm.wps.policy.parse.IntegerFactory">
<value>1</value>
</policyValue>
<policyValue
Name="rootNavigationStopLevel"
Factory="com.ibm.wps.policy.parse.IntegerFactory">
<value>1</value>
</policyValue>
<policyValue
Name="topNavigationNumRows"
Factory="com.ibm.wps.policy.parse.IntegerFactory">
<value>1</value>
</policyValue>
<policyValue
Name="topNavigationStartLevel"
Factory="com.ibm.wps.policy.parse.IntegerFactory">
<value>2</value>
</policyValue>
<policyValue
Name="topNavigationStopLevel"
Factory="com.ibm.wps.policy.parse.IntegerFactory">
<value>2</value>
</policyValue>
<policyValue
Name="sideNavigationStartLevel"
Factory="com.ibm.wps.policy.parse.IntegerFactory">
<value>3</value>
</policyValue>
<policyValue
Name="Version"
Factory="com.ibm.wps.policy.parse.StringFactory">
<value>1.0</value>
</policyValue>
</policy>
</policyList>

Updating a theme policy

If you are just updating a theme policy, use the following guidelines:
  • Export the theme policy.
  • Edit the values of the attributes to be updated.
  • Use the XML configuration interface to run addThemePolicyNode.xml which references the file that has the updated theme policy definition.

Extending and updating a theme policy

When updating, if you are also extending a theme policy by adding attributes to it, the attribute(s) must also be added to the root theme policy. Use the following guidelines to do this:
  • Export the entire theme policy structure
  • Edit the root theme policy.
  • Edit the theme policy to be updated by adding the attribute if the value is different than the root theme policy.
  • Run addThemePolicyNode.xml which references the file that has the updated definitions.
If you are just modifying the value of an attribute that already exists in a theme policy, use the following guidelines:
  • Export the theme policy you wish to modify.
  • Make the appropriate changes to the attribute.
  • Run addThemePolicyNode.xml which references the file that has the updated definitions.

Exporting a theme policy

Use the following code example exportThemePolicyNode.xml to export a theme policy. The file specified is the location to where the exported information is written. The following example exports all theme policies.

<?xml version="1.0" encoding="UTF-8"?>
<request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"
create-oids="true" type="export"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<portal action="locate">
<policy-node action="export" label="WebPage"
type="theme" path="">
<url>file:///c:/temp/exportThemePolicies.xml</url>
</policy-node>
</portal>
</request>

The following example exports only the TestThemePolicy theme policy:

<?xml version="1.0" encoding="UTF-8"?>
<request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"
create-oids="true" type="export"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<portal action="locate">
<policy-node action="export" label="WebPage"
type="theme" path="TestThemePolicy">
<url>file:///c:/temp/exportTestThemePolicy.xml</url>
</policy-node>
</portal>
</request>

Deleting a theme policy

Use the following code example deleteThemePolicyNode.xml to delete a theme policy.
Note: path is the "PznType" of the child policy to be deleted. "PznType" is the identifier of the policy used in the XML file. Specifically, "PznType" is the actual JCR (Java Content Repository) XPath name of this child node. XPath is a search language designed for selecting elements from an XML document (such as a theme policy). A policy is located in a search by an XPath or something that resembles the following: Root/Child1/Child2 .
<request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"
create-oids="true" type="update"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<portal action="locate">
<policy-node action="delete" label="WebPage"
type="theme" path="TestThemePolicy">
</policy-node>
</portal>
</request>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值