30.07.2013 Views

Customizing your IBM WebSphere Portal 7.0.0.2 Web experience ...

Customizing your IBM WebSphere Portal 7.0.0.2 Web experience ...

Customizing your IBM WebSphere Portal 7.0.0.2 Web experience ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Customizing</strong> <strong>your</strong> <strong>IBM</strong> <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> <strong>7.0.0.2</strong><br />

<strong>Web</strong> <strong>experience</strong> using the new theme framework<br />

Jon Lidaka (jjlidaka@us.ibm.com), <strong>IBM</strong><br />

September 2012<br />

© Copyright <strong>IBM</strong> Corporation 2012. All Rights Reserved.<br />

Summary: This detailed, step-by-step guide explains how to customize <strong>your</strong> <strong>IBM</strong><br />

<strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> <strong>7.0.0.2</strong> <strong>Web</strong> <strong>experience</strong> by using the new modularized theme framework.<br />

Table of Contents<br />

1 Introduction..........................................................................................................................1<br />

2 Inline theme customization..................................................................................................2<br />

2.1 Activating edit mode.....................................................................................................3<br />

2.2 Create a new page.......................................................................................................4<br />

2.3 The customization shelf...............................................................................................7<br />

2.4 Adding content.............................................................................................................7<br />

2.5 Changing the layout...................................................................................................10<br />

2.6 Changing the style.....................................................................................................11<br />

2.7 Drag and drop............................................................................................................12<br />

3 Connecting to <strong>Web</strong>DAV.....................................................................................................13<br />

3.1 Connecting to the theme administration entry points.................................................14<br />

3.2 Connecting to theme filestore entry point...................................................................17<br />

4 <strong>Customizing</strong> <strong>your</strong> <strong>Web</strong> <strong>experience</strong>....................................................................................19<br />

4.1 Create a new theme...................................................................................................19<br />

4.2 Create a new skin......................................................................................................23<br />

4.3 Create a layout...........................................................................................................27<br />

4.4 Create a style.............................................................................................................30<br />

4.5 Change the logo........................................................................................................32<br />

4.6 Create a dynamic-content spot..................................................................................38<br />

5 Theme optimization...........................................................................................................41<br />

5.1 Setting the theme profile............................................................................................41<br />

5.2 Create a custom profile..............................................................................................44<br />

6 Debugging.........................................................................................................................49<br />

6.1 Theme optimization debugging..................................................................................49<br />

6.2 Development mode....................................................................................................52<br />

7 Conclusion.........................................................................................................................52<br />

8 Resources.........................................................................................................................52<br />

9 Author biography...............................................................................................................53<br />

1


1 Introduction<br />

In this white paper we explore the process for customizing <strong>your</strong> <strong>Web</strong> <strong>experience</strong> and using the new<br />

theme optimization features within <strong>IBM</strong>® <strong><strong>Web</strong>Sphere</strong>® <strong>Portal</strong> <strong>7.0.0.2</strong>.<br />

The exercise is separated into the following sections:<br />

(1) Introduction<br />

(2) Overview of the out-of-box inline theme customization features<br />

(3) How to connect to the <strong>Web</strong>DAV entry points<br />

(4) Basics of a custom <strong>Web</strong> <strong>experience</strong>: creating a theme, skin, layout and style, etc.<br />

(5) Theme optimization features using profiles and modules<br />

(6) Debugging<br />

Sections 1, 2, 3 and 4 are independent of one another. If you are already familiar with the out-of-box<br />

inline customization features and connecting to <strong>Web</strong>DAV, it is recommended to start with Section 4. If<br />

you are familiar with the basics of creating a custom <strong>Web</strong> <strong>experience</strong> and would like to learn more<br />

about the new features in <strong>7.0.0.2</strong>, then start with Section 5.<br />

What you will learn<br />

At the end of this exercise, you will have an understanding of the theme customization features<br />

available out-of-box as well as the process for creating a new <strong>Web</strong> <strong>experience</strong>. You should also be<br />

able to re-brand the theme and provide a new “look and feel.”<br />

You can do this exercise at home with a freshly installed <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> <strong>7.0.0.2</strong> with Cumulative<br />

Fix (CF) 12 applied. For sections that require images or icons, you can substitute <strong>your</strong> own custom<br />

images and icons.<br />

Formatting/hints<br />

The following color codes are used in this paper:<br />

Blue: A file or directory<br />

Purple: A command to be executed<br />

NOTE: These colors are helpful to see the different types quickly, but they are not necessary to<br />

understanding the meaning. So if you are using black and white, that will work as well.<br />

Our server name here is localhost. Replace these server names with <strong>your</strong> local host name on which<br />

<strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> is installed.<br />

Environment<br />

We use <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> <strong>7.0.0.2</strong> with CF12 installed on <strong>IBM</strong> <strong><strong>Web</strong>Sphere</strong> Application Server (WAS)<br />

7.0. Apache Derby is configured as the underlying database management system, and the <strong>Portal</strong><br />

<strong>7.0.0.2</strong> theme is applied as the default. The files required for the lab are provided as a download to<br />

this paper.<br />

2 Inline theme customization<br />

The <strong>Portal</strong> <strong>7.0.0.2</strong> theme is new and is built by use of many similar aspects from the Page Builder<br />

architecture. There are many inline customization features integrated with the Page Builder<br />

architecture, many of which you activate by placing the page into Edit mode (by default, when you<br />

navigate to a page, it is in View mode.<br />

2


This section guides you through the process of using the inline customization features. Figure 1<br />

shows the Page Builder theme out-of-box in View mode.<br />

Figure 1. <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> <strong>7.0.0.2</strong> theme<br />

2.1 Activating edit mode<br />

1. Select the page mode toggle in the header of the theme (highlighted in red in figure 2).<br />

Figure 2. Page mode toggle<br />

2. This puts the page into Edit mode, and new items are displayed on the page (see figure 3). The<br />

edit mode of a page exposes the inline customization features of the theme. The controls<br />

displayed are for the customization shelf, hidden content container, alternate portlet modes, drag<br />

and drop, and page creation from the actions menu.<br />

3


Figure 3. Edit mode controls<br />

2.2 Create a new page<br />

Create a sibling page:<br />

1. Put the page in Edit mode and open the Actions menu (see figure 4).<br />

Figure 4. Actions menu button<br />

2. Select the New Sibling Page option from the menu (see figure 5).<br />

Figure 5. New Sibling Page option<br />

4


3. In the Create Page window, name the new peer page and, if you have permissions, you have the<br />

option to create a public or private page (see figure 6).<br />

Figure 6. Create Page window<br />

4. Name <strong>your</strong> new page and click the Create Page button (see figure 7).<br />

Figure 7. Create Page button<br />

5. A window displays, communicating that the page is being created and, when done, the new page<br />

will display on the primary level of navigation and will become the selected page (see figure 8).<br />

5


Figure 8. New “Lab Page” displaying<br />

Create a child page:<br />

1. Open the Actions menu (recall figure 4); select New Child Page from the menu (see figure 9).<br />

Figure 9. New Child Page option<br />

2. In the Create Page window, name the new child and, if you have permissions, you have the<br />

option to create a public or private page. Name <strong>your</strong> new page and click Create Page.<br />

3. A window displays, communicating that the page is being created and, when done, the new child<br />

page displays in the secondary navigation and becomes the selected page (see figure 10).<br />

Figure 10. New Lab Child Page displaying<br />

6


2.3 The customization shelf<br />

1. Put the page into Edit mode; click the Customize button on the page toolbar (see figure 11).<br />

Figure 11. Customize button<br />

The customization shelf displays above the toolbar (see figure 13), from which you can customize<br />

the page by using the Add Content, Change Style, and Change Layout actions.<br />

Figure 13. Customization shelf<br />

2.4 Adding content<br />

1. Put the page in Edit mode and click the Customize button; once the customization shelf displays,<br />

the Add Content tab is shown by default.<br />

2. You can select a category from the menu on the left-hand side of the shelf; for this exercise,<br />

select All (see figure 14), to display all portlets and widgets that can be added to the page.<br />

Figure 14. All Content tab<br />

7


3. The portlets and widgets display in the main panel of the shelf. Click the Add-to-page plus-sign<br />

icon on the item you want to add to the page; in this case, click the icon for the “About<br />

<strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong>” item (see figure 15).<br />

Figure 15. About <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong><br />

The item you add to the page displays in Preview mode in the main container in the layout (see<br />

figure 16).<br />

Figure 16. Item in Preview mode<br />

4. The shelf also allows you to search for content instead of going through content page by page.<br />

Type “world” within the search box and press Enter to view the results (see figure 17).<br />

Figure 17. Search “world”<br />

This displays one result, the World Clock portlet (see figure 18).<br />

8


Figure 18. World Clock portlet<br />

5. An alternative way to add an item to the page is to use drag and drop. Hover over the “World<br />

Clock” item in the search results; the move icon appears (see figure 19), as long as you are not<br />

over the plus icon or the title (the title can be selected to view additional details).<br />

Figure 19. Move icon<br />

6. Drag the portlet from the shelf to a container in the layout; notice a preview outline appears within<br />

the container, confirming it is valid to drop the item from the shelf to the page (see figure 20).<br />

Figure 20. Dragging portlet from shelf to container<br />

7. After you have added two portlets, using the two methods from the shelf, click the Save & Exit<br />

button (see figure 21) to persist the changes to the layout, and exit Edit mode. This synchronizes<br />

the page area so that you can see all content (see figure 22).<br />

9


Figure 21. Save & Exit button<br />

Figure 22. Synchronized page area<br />

2.5 Changing the layout<br />

1. Create a new page and put it in Edit mode. Notice that the page by default has two containers<br />

highlighted in the main content area in figure 23.<br />

Figure 23. Two default containers<br />

2. Open the customization shelf and select the Change Layout tab (see figure 24), to display the<br />

layout choices in the main panel of the shelf.<br />

10


Figure 24. Change Layout tab<br />

3. Select the “3 column center” option as shown in figure 25, and click the Save & Exit button on the<br />

page toolbar.<br />

Figure 25. 3 column center<br />

4. The page refreshes. Put the page back into Edit mode; you now see three containers highlighted<br />

(see figure 26).<br />

Figure 26. Three containers<br />

The layout of the page has now been changed. You can continue to customize the page by adding<br />

content or changing the style. You can change the layout of a page that already has content as well.<br />

The page builder framework will consolidate content, if you decrease containers on the page, and will<br />

add empty containers, if the number of containers increases on the page.<br />

All out-of-box layouts include a Hidden Content container at the top of the layout. As discussed, you<br />

can display this container by using the Hidden Content button on the page toolbar. To learn more<br />

about hidden content, refer to the “Hiding content" and “Layouts" <strong>Portal</strong> product documentation<br />

topics.<br />

2.6 Changing the style<br />

1. Navigate to a page that has been created during this exercise, put the page in edit mode, and<br />

open the customization shelf.<br />

11


2. Select the Change Style tab on the customization shelf (see figure 27), to display the style<br />

choices in the main panel of the shelf. The pages that we've created thus far inherit the style from<br />

the parent, so none of the styles are selected by default on the shelf.<br />

Figure 27. Change Style button<br />

3. Select “Red” from the styles displayed on the shelf; a border displays around this item on the<br />

shelf, showing it is selected, and the style is applied to the page (see figure 28).<br />

Figure 28. “Red” selected<br />

4. Click the Save & Exit button from the page toolbar to persist the style to the page.<br />

Using styles allows you to have a set of predefined colors/graphics that users can choose from,<br />

without having multiple themes. These styles are scoped to the theme that is set for the page. To<br />

Learn more, refer to the Styles product documentation topic.<br />

2.7 Drag and drop<br />

1. Navigate to a page where we created content (About <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> or World Clock), and put<br />

the page in Edit mode.<br />

2. Hover over the titlebar of the World Clock portlet; the move cursor displays (see figure 28).<br />

12


Figure 28. Move cursor<br />

3. Click and drag the portlet. You can move to another container or rearrange in the same container.<br />

As you drag it, a Preview image displays, indicating where the portlet will be placed if dropped<br />

(see figure 29).<br />

Figure 29. Preview image<br />

4. After rearranging the content on the page, click the Save & Exit button from the page toolbar, to<br />

persist the changes. To learn more, refer to the Drag and drop topic.<br />

3 Connecting to <strong>Web</strong>DAV<br />

In this section, we step through the process of connecting to <strong>Web</strong>DAV, explaining the purpose of<br />

each entry point and the directory structure of the files available on <strong>Web</strong>DAV.<br />

The theme contains three types of files: JavaScript TM , dynamic content [JavaServer Pages (JSPs)],<br />

and static resources. The majority of JavaScript and all the dynamic content are deployed as a WAR<br />

file. The static resources are deployed on <strong>Web</strong>DAV.<br />

You can use <strong>Web</strong>DAV for <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> to administer portal themes and skins by using the<br />

<strong>Web</strong>DAV standard operating system tools. This way you can browse, read, and write themes and<br />

skins as well as work with the static resources such as Cascading Style Sheets (CSS) and images.<br />

Themes and skins can also be edited and managed directly via static HTML files stored in the<br />

<strong>Web</strong>DAV file store. For more details about working with <strong>Web</strong>DAV, refer to the “Connecting to the<br />

<strong>Portal</strong> <strong>Web</strong>DAV” topic.<br />

13


3.1 Connecting to the theme administration entry points<br />

The themelist entry point is for working with themes from an administrative perspective, such as<br />

creating a new theme, deleting a theme, working the metadata, or modifying the title.<br />

Connecting to the themelist entry point:<br />

1. Go to the desktop of the virtual image and launch AnyClient, using the “AnyClient (for <strong>Web</strong>DAV)”<br />

icon (see figure 30).<br />

Figure 30. AnyClient desktop icon<br />

2. Once AnyClient is launched, select File --- Site Manager (see figure 31).<br />

Figure 31. AnyClient window<br />

3. The Connect window displays; click the New button in the bottom left-hand corner (see figure 32).<br />

14


Figure 32. Connect window<br />

4. This creates a new entry under Site Manager, called “New Site”; double-click on the New Site title<br />

and rename it “wp themelist” (see figure 33).<br />

Figure 33. wp themelist<br />

5. The form shown in figure 34 will be enabled; fill in the fields using these values:<br />

• Host: http://localhost:10039/wps/mycontenthandler/dav/themelist/<br />

• Username: wpsadmin<br />

• Password: wpsadmin<br />

• Protocol: <strong>Web</strong>DAV<br />

15


Figure 34. AnyClient window<br />

6. Click Connect. It takes a few seconds to connect, but when it does, the contents of the themelist<br />

entry point are displayed as shown in figure 35.<br />

Figure 35. Contents of themelist entry point<br />

The <strong>Portal</strong> <strong>7.0.0.2</strong> theme is located within the “ibm.portal.7002Theme” folder, the legacy <strong>Portal</strong> theme<br />

is located within the “ibm.portal.theme.<strong>Portal</strong>” folder, and the Page Builder theme is located within the<br />

“csa2.theme” folder, at which location you can copy new folders to <strong>Web</strong>DAV, which will register them<br />

as a new theme (to be discussed later).<br />

Connecting to the skinlist entry point:<br />

The skinlist entry point is for working with skins from an administrative perspective, such as creating a<br />

new skin, deleting a skin, or modifying the title.<br />

1. Follow Steps 1---3 from the previous “Connecting to the themelist entry point” subsection.<br />

2. A new entry is created under Site Manager, called “New Site”; double-click on the New Site title<br />

and rename it “wp skinlist” (see figure 36).<br />

Figure 36. wp skinlist<br />

16


3. The form shown in figure 37 will be enabled; fill in the fields using these values:<br />

• Host: http://localhost:10039/wps/mycontenthandler/dav/skinlist/<br />

• Username: wpsadmin<br />

• Password: wpsadmin<br />

• Protocol: <strong>Web</strong>DAV<br />

Figure 37. AnyClient window<br />

4. Click Connect. After a few seconds <strong>Web</strong>DAV will connect, and the contents of the skinlist entry<br />

point are displayed as shown in figure 38.<br />

Figure 38. Contents of skinlist entry point<br />

The skins with the prefix “ibm.portal.7002” are designed for the <strong>Portal</strong> <strong>7.0.0.2</strong> theme. At this location<br />

you can copy new folders to <strong>Web</strong>DAV, which will register them as new skins (as discussed below).<br />

3.2 Connecting to theme filestore entry point<br />

The filestore entry point is not for the administration of themes and skins. The fs-type1 entry point is<br />

used for storing and managing static resources and, after creating a theme or skin, you connect to<br />

the fs-type1 entry point to modify the static templates.<br />

17


1. Follow Steps 1--3 from the previous “Connecting to the skinlist entry point” subsection.<br />

2. A new entry is created under Site Manager, called “New Site”; double-click on the New Site title<br />

and rename it “wp filestore.”<br />

3. The form shown in figure 39 will be enabled, fill in the fields using these values:<br />

• Host: http://localhost:10039/wps/mycontenthandler/dav/fs-type1/<br />

• Username: wpsadmin<br />

• Password: wpsadmin<br />

• Protocol: <strong>Web</strong>DAV<br />

Figure 39. <strong>Web</strong>Drive window<br />

4. Click Connect. After a few seconds, it will connect, after which the window in figure 40 displays<br />

the contents of the fs-type1 entry point.<br />

Figure 40. Contents of fs-type1 entry point<br />

The folders displayed in the above figure for the fs-type1 entry point store static resources for the<br />

theme framework (<strong>Web</strong>DAV prevents the deletion of these folders) and are defined as follows:<br />

18


• /themes. Use this folder to store resources that are associated with themes, such as theme<br />

templates. You can also use it to store nested skins. Each subfolder represents one theme.<br />

• /skins. Use this folder to store global skins. Typically, each subfolder of this folder represents one<br />

global skin.<br />

• /layout-templates. Use this folder to store templates for layouts that can be used across themes.<br />

Typically, each subfolder represents one layout template. In this paper we scope the layouts to a<br />

theme, as discussed above.<br />

• /common-resources. Use this folder to share common resources between different themes, so<br />

that they can be managed in a single place.<br />

• /iwidgets. Use this folder to place widgets in. They are automatically deployed into the portal.<br />

4 <strong>Customizing</strong> <strong>your</strong> <strong>Web</strong> <strong>experience</strong><br />

The theme consists of a collection of static HTML templates that can inject server-side logic using<br />

dynamic-content spots. The introduction of <strong>Web</strong>DAV provides a logical separation of static and<br />

dynamic resources that allows for easy customization of themes, skins, and layouts.<br />

Styles have been further optimized for performance and ease of customization by exploitation of the<br />

latest CSS3 features for linear gradients, drop shadows, and rounded corners. These new features<br />

give you flexibility to build extraordinary <strong>Web</strong> <strong>experience</strong>s.<br />

4.1 Create a new theme<br />

The best way to start creating <strong>your</strong> own custom theme is by copying an existing theme. This ensures<br />

that <strong>your</strong> theme has all the required elements for it to function.<br />

NOTE: Do not modify the themes directly, as the themes can be updated by service fix packs and<br />

override <strong>your</strong> changes.<br />

Create a new theme:<br />

1. Mount the “themelist” <strong>Web</strong>DAV entry point with <strong>your</strong> <strong>Web</strong>DAV client:<br />

http://localhost:10039/wps/mycontenthandler/dav/themelist<br />

2. Copy the “ibm.portal.7002Theme” folder to the desktop and rename it “labTheme”.<br />

3. Give the theme a new title. To do this, open the file:<br />

/labTheme/metadata/localized_en.properties<br />

and set the title to “Lab Theme” (see Figure 41).<br />

Figure 41. localized_en.properties in editor<br />

19


NOTE: You can right-click on the file and select Edit with Notepad++. If you do not change the<br />

title, you will receive multiple themes with the same title in selection lists.<br />

4. Open theme template file, located here: /labTheme/nls/theme_en.html<br />

NOTE: The theme.html file in the root directory of the theme redirects to a localized template<br />

located in the “nls” folder. You must modify the localized template for the changes to render. To<br />

learn more about theme templates, refer to “Working with Page Builder theme templates<br />

(theme.html)” and “Removing template localization for the theme and skin.”<br />

5. Directly under the element, insert a element with the text “Lab Theme” inside to<br />

identify this new theme (see figure 42).<br />

Figure 42. theme_en.html identification in editor<br />

When you apply this theme to a page, the identifying will display and confirm that you<br />

applied the new theme since everything else will be the same as the <strong>Portal</strong> <strong>7.0.0.2</strong> theme.<br />

6. Copy the “labTheme” folder back to the /themelist/ folder (see figure 43).<br />

Figure 43. labTheme folder copied<br />

• After the folder is done copying to <strong>Web</strong>DAV, <strong>your</strong> new theme is now defined in the <strong>Portal</strong><br />

database. You can assign the theme to pages as required. To customize <strong>your</strong> theme, you can<br />

edit the theme files in <strong>Web</strong>DAV.<br />

• To perform administrative customization (title, description, metadata), continue to use the<br />

/themelist/ entry point. To customize the templates and static resources, use the /fs-type1/ entry<br />

point.<br />

• At this point <strong>your</strong> theme is still pointing to the same Default.jsp and dynamic content spots as the<br />

out-of-box <strong>Portal</strong> <strong>7.0.0.2</strong> theme.<br />

At this time no skin is assigned to the theme, and if applied to a page, the fallback skin would be<br />

displayed. It is a best practice to assign a skin as the default:<br />

1. Select Administration as shown in figure 44.<br />

20


Figure 44. Administration option<br />

2. Go to Themes and Skins, select the “Lab Theme” option, and click Edit theme (see figure 45).<br />

Figure 45. Themes and Skins window<br />

3. Select the “<strong>Portal</strong> <strong>7.0.0.2</strong> – Hidden – portal default” and assign it to the Lab Theme by clicking<br />

the right-arrow button (see figure 46).<br />

Figure 46. <strong>Portal</strong> <strong>7.0.0.2</strong> – Hidden – portal default<br />

4. Click OK; at this time <strong>your</strong> theme has been created and defined within <strong>Portal</strong>, ready to use.<br />

Apply new theme to a page:<br />

1. Open Mozilla Firefox; there is a shortcut on the desktop of the virtual image (see figure 47).<br />

21


Figure 47. Firefox shortcut<br />

2. Go to http://localhost:10039/wps/portal<br />

3. Log in with username “wpsadmin” and password “wpsadmin”.<br />

4. Create a new page, open the Actions menu, and select Edit Page Properties (see figure 48).<br />

Figure 48. Edit Page Properties<br />

5. Under the Theme menu, select “Lab Theme” (see figure 49).<br />

Figure 49. Lab Theme<br />

6. Submit <strong>your</strong> changes by clicking OK. The new theme is now applied to the page and should look<br />

like that shown in figure 50.<br />

Figure 50. New theme<br />

You are now able to make updates to the theme template from <strong>Web</strong>DAV and, after the changes are<br />

persisted back to <strong>Web</strong>DAV, you can refresh the page to render the modifications.<br />

It is not required that you keep the Lab Theme element in the template; it was put in the<br />

template so that it was easy to distinguish between this theme and the default, out-of-box theme. To<br />

learn more, refer to “Copying the theme.”<br />

22


4.2 Create a new skin<br />

You can create skins to implement a custom look and feel. A successful approach to creating custom<br />

skins is copying an existing skin and then adding images and other custom resources. Copying either<br />

the <strong>Portal</strong> <strong>7.0.0.2</strong> Hidden or Standard skin is the best way to ensure that <strong>your</strong> custom skin contains all<br />

the required elements.<br />

The <strong>Portal</strong> <strong>7.0.0.2</strong> – Hidden skin does not display any decorations in Page View mode, but it will<br />

display a titlebar and actions menu when in Edit mode. This skin was created for <strong>IBM</strong> <strong>Web</strong> Content<br />

Manager (WCM) content. The <strong>Portal</strong> <strong>7.0.0.2</strong> – Standard skin always displays a titlebar and actions<br />

menu, regardless of page mode.<br />

NOTE: Do not modify the <strong>Portal</strong> <strong>7.0.0.2</strong> skins directly, as this theme can be updated by service fix<br />

packs and override <strong>your</strong> changes.<br />

Create a new skin:<br />

1. Mount the skinlist <strong>Web</strong>DAV entry point with <strong>your</strong> <strong>Web</strong>DAV client:<br />

http://localhost:10039/wps/mycontenthandler/dav/skinlist<br />

2. Copy the “ibm.portal.7002Standard” folder to the desktop and rename it “labSkin”.<br />

3. Give the theme a new title. To do this, open the file:<br />

/labSkin/metadata/localized_en.properties<br />

and set the title to Lab Skin (see figure 51).<br />

Figure 51. localized_en.properties in editor<br />

NOTE: You can right-click on the file and select “Edit with Notepad++”. If you do not change the title,<br />

you will receive multiple skins with the same title in selection lists.<br />

4. Open the skin template file, located here: /labSkin/nls/skin_en.html<br />

NOTE: The skin.html file in the root directory of the skin folder redirects to a localized template<br />

located in the “nls” folder. You must modify the localized template for the changes to render. To<br />

learn more, refer to the “Skin Templates" topic.<br />

5. Locate the header element for the titlebar () and add the portlet description dynamic-content<br />

spot to the titlebar. To do this, locate this line of code:<br />

<br />

and add this piece of code before the :<br />

23


Figure 52 shows what the source code should look like after you add the new line of code.<br />

Figure 52. Modified source code<br />

When you apply this skin to a layout control the titlebar description will display and confirm that you<br />

applied the new skin since everything else will be the same as the Page Builder standard skin.<br />

6. Copy the labSkin folder back to the /skinlist/ folder (see figure 53).<br />

Figure 53. labSkin folder copied<br />

After the folder is done copying to <strong>Web</strong>DAV <strong>your</strong> new skin is now defined in the <strong>Portal</strong> database. You<br />

can assign the skin to layout controls as required. For more information, refer to the “Create a skin”<br />

topic.<br />

Apply new skin to a layout control:<br />

1. Open Firefox and go to http://localhost:10039/wps/portal<br />

2. Log in with username “wpsadmin” and password “wpsadmin”<br />

3. Select Administration and then select Themes and Skins on the left-hand navigation.<br />

4. Select Lab Theme from the Themes list, and click the Edit theme button (see figure 54).<br />

24


Figure 54. Edit Theme<br />

5. In the Edit view of the theme, select “Lab Skin” from the selection panel and then click the rightarrow<br />

button between the All skins and Skins for this theme panels (see figure 55).<br />

Figure 55. Lab Skin<br />

6. Click “Set as default” and click OK, to save the changes.<br />

7. Navigate back to the page on which you applied the Lab Theme, put it in Edit mode, and open<br />

the customization shelf.<br />

8. The Add Content panel is displayed by default; go to the All category and add the About<br />

<strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> portlet to the page (see figure 56).<br />

Figure 56. About <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> portlet<br />

25


9. Click Save & Exit from the page toolbar to persist the changes.<br />

After the page refreshes the contents of the portlet will display, and the new Lab Skin will display,<br />

wrapping the portlet contents. You can confirm that is the new skin because the portlet description is<br />

displayed in the titlebar (see figure 57).<br />

Figure 57. Portlet description<br />

Referencing static resources in the skin:<br />

1. Connect to the fs-type1 <strong>Web</strong>DAV entry point:<br />

http://localhost:10039/wps/mycontenthandler/dav/fs-type1/<br />

2. Go to the “lab files” (shortcut on desktop) and move the “skinIcon.png” to this location on<br />

<strong>Web</strong>DAV: dav:fs-type1/themes/labTheme/images/<br />

3. Copy the skin template, skin_en.html, to the local machine and open it, located here:<br />

dav:fs-type1/skins/labSkin/nls/skin_en.html<br />

4. Locate the header element for the titlebar (), and on the next line beneath that element,<br />

add this line of code:<br />

<br />

Figure 58 shows the skin_en.html after adding the image to the code.<br />

26


Figure 58. Code with image added<br />

Note that, when referencing static resources in the theme or skin, the path's root is the theme<br />

directory (for example, /fs-type1/themes/labTheme/).<br />

5. Save the file and copy it back to <strong>Web</strong>DAV.<br />

6. Refresh the page; figure 59 shows the skin referencing the image from <strong>Web</strong>DAV.<br />

Figure 59. Skin referencing image<br />

4.3 Create a layout<br />

1. Connect to the fs-type1 <strong>Web</strong>DAV entry point:<br />

http://localhost:10039/wps/mycontenthandler/dav/fs-type1/<br />

2. Navigate to: dav:fs-type1/themes/labTheme/layout-templates. Figure 60 shows the<br />

folder structure of the layout-templates folder, in which each folder is a layout that displays within<br />

the “Change Layout” panel on the customization shelf.<br />

Figure 60. layout-templates folder<br />

27


3. Copy the “1Column” folder to the desktop, rename it “labLayout”, and open it.<br />

4. Go to the “lab files” (shortcut on desktop), move the labLayout/icon.gif file to the labLayout folder,<br />

and overwrite the file that is currently there.<br />

5. Open the layout template, layout.html, from the labLayout folder and inside the layout template,<br />

change this line:<br />

<br />

to have an inline style that will display a blue border around the container to identify this as a<br />

new layout, as follows:<br />

div style="border: 2px solid blue" class="component-container wpthemeCol<br />

wpthemeCol-1 ibmDndColumn wpthemeLeft" name="ibmMainContainer"><br />

6. Save the file and copy the entire labLayout folder back to the dav:fstype1/themes/labTheme/layout-templates<br />

folder. Figure 61 shows the folder structure<br />

after copying the folder.<br />

Figure 61. Folder structure after copying folder<br />

7. Copy the layouts.json file to the desktop, located here:<br />

dav:fs-type1/themes/labTheme/system/layouts.json<br />

8. Open the layouts.json file that was copied to the local machine; this will display as shown in<br />

listing 1.<br />

Listing 1. layouts.json file<br />

{ localizationPackageName:'com.ibm.bundles',<br />

localizationBundleName:'Shelf', identifier:'label', items: [<br />

{'label':'change_layout_col1','url':ibmCfg.themeConfig.theme<strong>Web</strong>DAVBaseU<br />

RI+'layouttemplates/1Column/','id':'1Column','thumbnail':ibmCfg.themeConfig.themeR<br />

ootURI+'/layout-templates/1Column/icon.gif','help':''},<br />

.<br />

.<br />

.<br />

28


9. Copy the first line from the “items” array, shown here:<br />

{'label':'change_layout_col1','url':ibmCfg.themeConfig.theme<strong>Web</strong>DAVBaseUR<br />

I+'layouttemplates/1Column/','id':'1Column','thumbnail':ibmCfg.themeConfig.themeR<br />

ootURI+'/layout-templates/1Column/icon.gif','help':''},<br />

10. Paste as first line in the “items” array, such as shown in listing 2.<br />

Listing 2. One Column layout duplicated in layouts.json file<br />

{ localizationPackageName:'com.ibm.bundles',<br />

localizationBundleName:'Shelf', identifier:'label', items: [<br />

{'label':'change_layout_col1','url':ibmCfg.themeConfig.theme<strong>Web</strong>DAVBaseURI+<br />

'layouttemplates/1Column/','id':'1Column','thumbnail':ibmCfg.themeConfig.themeRoot<br />

URI+'/layout-templates/1Column/icon.gif','help':''},<br />

{'label':'change_layout_col1','url':ibmCfg.themeConfig.theme<strong>Web</strong>DAVBaseURI+<br />

'layouttemplates/1Column/','id':'1Column','thumbnail':ibmCfg.themeConfig.themeRoot<br />

URI+'/layout-templates/1Column/icon.gif','help':''},<br />

11. Change the first item to apply the labLayout properties:<br />

{'label':'Lab<br />

Layout','url':ibmCfg.themeConfig.theme<strong>Web</strong>DAVBaseURI+'layouttemplates/labLayout/','id':'labLayout','thumbnail':ibmCfg.themeConfig.th<br />

emeRootURI+'/layout-templates/labLayout/icon.gif','help':''},<br />

12. Clear the browser cache and verify that, when you open the customization shelf for a page with<br />

the Lab Theme applied, the Change Layout panel displays the new Lab Layout. Figure 62 shows<br />

the Lab Layout on the shelf.<br />

Figure 62. Lab Layout<br />

At this point, you can select the Lab Layout and apply it to a page. Figure 63 shows the layout applied<br />

to the page that we created for the new skin section. For more information, refer to the “Layouts"<br />

topic.<br />

29


Figure 63. Layout applied to the page<br />

4.4 Create a style<br />

1. Connect to the fs-type1 <strong>Web</strong>DAV entry point, using<br />

http://localhost:10039/wps/mycontenthandler/dav/fs-type1/<br />

2. Navigate to dav:fs-type1/themes/labTheme/css. Figure 64 shows the folder structure of<br />

the css folder. The folders contain styles that are displayed when selecting them from the<br />

Change Style panel on the customization shelf.<br />

Figure 64. css folder structure<br />

3. Create a new folder on the desktop named “lab”.<br />

4. Go to the “lab files” and copy the file named labStyle/icon.gif to the lab folder.<br />

5. Create a new file inside the lab folder named lab.css, and open “lab.css”.<br />

6. Place the code in listing 3 inside the lab.css file. Copying these lines of code will override any<br />

styles that are in the default styles, and for this lab this is easiest way to create a new look.<br />

30


Listing 3. Code to place in lab.css file<br />

.wpthemeHeader {background-color: #1C3D69;}<br />

.wpthemeBanner {background: none;border-bottom: 0;}<br />

.wpthemeBannerInner {background: -moz-linear-gradient(center top , #648EC9<br />

0%, #164A7E 100%) repeat scroll 0 0 transparent;border-bottom: 0;}<br />

.wpthemePrimaryNav .wpthemeSelected a,<br />

.wpthemePrimaryNav .wpthemeSelected a:focus,<br />

.wpthemePrimaryNav .wpthemeSelected a:hover,<br />

.wpthemePrimaryNav .wpthemeSelected a:active,<br />

.wpthemePrimaryNav li a:focus,<br />

.wpthemePrimaryNav li a:hover,<br />

.wpthemePrimaryNav li a:active {<br />

border-left-color: #1C3D69;<br />

border-right-color: #1C3D69;<br />

box-shadow: none;<br />

background: rgba(233,233,233, .1);<br />

}<br />

7. Copy the lab folder to dav:fs-type1/themes/labTheme/css<br />

8. Open the file dav:fs-type1/themes/labTheme/system/style.json. This file contains<br />

the style definitions that are displayed on the customization shelf.<br />

9. Within the file, add a definition for the Lab Style after the “white” definition. Here is the line of<br />

code to add:<br />

,{'label':'Lab<br />

Style','id':'lab.css','url':'css/lab/lab.css','thumbnail':ibmCfg.themeCo<br />

nfig.themeRootURI+'/css/lab/icon.gif','help':''}<br />

NOTE: The comma at the beginning is important, so as to start a new item for the object.<br />

10. At this point you can now navigate to a page with the Lab Theme applied and view the new style<br />

on the Change Style panel of the customization shelf. Figure 65 shows the style defined on the<br />

shelf, and figure 66 shows the style applied to a page.<br />

Figure 65. Style defined on shelf<br />

31


Figure 66. Style applied to page<br />

For more information, refer to the “Creating a theme” topic.<br />

4.5 Change the logo<br />

Changing the default <strong>IBM</strong> logo<br />

Out of the box, an <strong>IBM</strong> logo is displayed next to the common actions of the theme, but you can easily<br />

change this logo:<br />

1. Navigate to a page or create a page with the Lab Theme applied and, using the customization<br />

shelf, change the style to “Lab Style”. Save the page.<br />

2. Open Firebug by clicking the “bug” icon in the bottom right-hand corner of Firefox.<br />

3. Select the inspector tool from the Firebug toolbar in the upper left-hand corner of the Firebug<br />

panel (see figure 67).<br />

Figure 67. Inspector tool icon<br />

4. As you hover over elements on the page, you will see a blue highlight around the element, and<br />

the HTML panel in Firebug displays the element information.<br />

5. Hover over the <strong>IBM</strong> logo in the top right-hand corner of the theme (see figure 68) and click it. This<br />

stops the Inspector from continuing to the next element, and the information will persist in the<br />

Firebug panel.<br />

32


Figure 68. <strong>IBM</strong> logo highlighted<br />

6. At this point we can start to apply the new logo inline. In the Style panel of Firebug, you should<br />

see a style defined for “.wpthemeBanner .wpthemeBranding img” (see figure 69).<br />

Figure 69. Style definition<br />

7. We can modify the style inline to set new properties; for this exercise we want to use the white<br />

logo from the default sprite. To do this, change the background position by clicking “0 -422px”<br />

and setting it to “0 -448px” (see figure 70).<br />

33


Figure 70. Change background position<br />

The white <strong>IBM</strong> logo displays (see figure 81).<br />

Figure 81. White <strong>IBM</strong> logo<br />

8. At this point you can now copy the style override to Lab Style. Copy the “Lab Style” source from<br />

<strong>Web</strong>DAV to the local machine: dav:fs-type1/themes/labTheme/css/lab/lab.css<br />

9. Place the following line of code at the end of the file, taken from the Firebug panel:<br />

.wpthemeBanner .wpthemeBranding img {background-position: 0 -448px;}<br />

10. Copy lab.css back to <strong>Web</strong>DAV. Refresh the page; you will see the white logo is now displayed in<br />

the theme.<br />

You should now be familiar with using the Firebug inspector tool and how easy it is to modify the style<br />

and customize a logo. You can change the background image, size, and other attributes to<br />

accommodate <strong>your</strong> company's re-branding. If you have no need for a logo in the place where the <strong>IBM</strong><br />

branding is located, you can add the attribute “display: none” so it won't display.<br />

Display and change the logo default header location<br />

The <strong>IBM</strong> logo that was modified in the beginning of this exercise is in an abnormal location for<br />

branding. Most re-branding requires a logo in the top left corner of the theme. Out of box we have an<br />

element that is already in place that can be customized.<br />

1. Go to the lab files and copy the file named “labLogo.png” to this location on <strong>Web</strong>DAV:<br />

dav:fs-type1/themes/labTheme/css/images/<br />

2. Open the lab.css file that you copied to <strong>your</strong> local machine and copy this line of code to the<br />

bottom of the file: .wpthemeLogo { display: block;}<br />

3. Copy the lab.css file to <strong>Web</strong>DAV and refresh the page; you now see a <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> logo<br />

displayed in the top header (see figure 82).<br />

34


Figure 82. <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> logo<br />

4. Click the Firebug inspector tool and select the <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> logo. In the Firebug Style panel<br />

notice the style set in lab.css as well as the style to override for customization (see figure 83).<br />

Figure 83. Firebug Style panel<br />

5. At this point you can now modify the lab.css “wpthemeLogo” style class with the overrides. There<br />

four (4) items you need to customize:<br />

● background-image<br />

● background-position<br />

● width<br />

● height<br />

Right-click on the .wpthemeLogo class and select New Property (see figure 84).<br />

35


Figure 84. New Property option<br />

6. Type “background-image:” for the property name; the cursor will automatically move to the<br />

value and use url(“../images/labLogo.png”) (see figure 85) and, as soon as <strong>your</strong> are<br />

done typing, the logo will appear (see figure 86).<br />

Figure 85. url(“../images/labLogo.png”)<br />

Figure 86. Logo displaying<br />

7. Now choose to either manually add the additional properties to the lab.css wpthemeLogo class,<br />

or use the class from the master style layer to test what the modifying properties will look like.<br />

Before modifying values, however, we must determine the width/height of the new logo by<br />

hovering over the URL of the logo (see figure 87); you can see it is 125x55 px.<br />

Figure 87. Width/height of new logo<br />

36


To add the additional properties you can right-click on the lab.css wpthemeLogo, as you did in the<br />

previous step, and fill in the values.<br />

To modify the wpthemeLogo from the master style layer, you can click directly on the property<br />

such as “width” and type a new value or use the arrow keys to increase/decrease the value (see<br />

figure 88. The width of the logo should be set to 125px, and the height set to 55px.<br />

Figure 88. Modify from master style layer<br />

Firebug also makes it simple to enable/disable classes that are already defined for an element:<br />

Just click the “ ” sign that is displayed to the left-hand side of the property name as you hover<br />

over it. This comes in handy for the “background-position” property as our lab logo does not<br />

require this property (see figure 89).<br />

Figure 89. Enable/disable classes<br />

8. At the end of the modification process we will come up with the style definition for the<br />

wpthemeLogo. Copy the code in listing 4 into lab.css and overwrite the previous definition for<br />

wpthemeLogo.<br />

Listing 4. Code to copy into lab.css<br />

.wpthemeLogo{<br />

display: block;<br />

background-position: 0 0;<br />

background-image: url("../images/labLogo.png");<br />

width: 125px;<br />

height: 55px;<br />

}<br />

9. Copy lab.css back to <strong>Web</strong>DAV and refresh the page; the new logo is displayed in the header<br />

(see figure 90).<br />

37


Figure 90. New logo in header<br />

To learn more, refer to the <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> wiki article, “Change the theme logo.”<br />

4.6 Create a dynamic-content spot<br />

1. Go to the Page Builder WAR deployed in <strong>Portal</strong> at this location:<br />

C:\ibm\websphere\portalserver\theme\wp.theme.modules\webapp\installedApp<br />

s\ThemeModules.ear\ThemeModules.war\themes\html\dynamicSpots<br />

Figure 91 displays the folder contents, in which the JSPs are the dynamic content spots.<br />

Figure 91. Folder contents<br />

2. Create a new file named “labDynamicContent.jsp”, open it, place the following code in the file,<br />

and then save:<br />

<br />

Page ID:<br />

${wp.identification[wp.selectionModel.selected.contentNode]}<br />

NOTE: For this exercise we have simplified where to add the dynamic content JSP to the out-ofbox<br />

theme WAR; however, you should not do this in production or staging as applying service will<br />

overwrite <strong>your</strong> changes.<br />

3. Access the WAS console (there is a bookmark on the toolbar of the browser):<br />

https://localhost:10032/ibm/console/logon.jsp<br />

38


4. Log in using “wpsadmin” for both the servername and password.<br />

5. Navigate to Resources --- Resource Environment --- Resource environment providers ---<br />

WP DynamicContentSpotMappings.<br />

6. Select “Custom properties” on the right-hand side of the window (see figure 92).<br />

Figure 92. Custom properties option<br />

7. Click the New button, as shown in figure 93, and enter the name “labDynamicContent” as the ID<br />

of the mapping.<br />

Figure 93. New button<br />

8. Enter the following value as the URI of the dynamic content:<br />

res:/wps/themeModules/themes/html/dynamicSpots/labDynamicContent.jsp<br />

Figure 94 shows the properties set for the Resource Environment Provider (REP).<br />

39


Figure 94. Properties set for REP<br />

9. Click OK, save the changes, and restart <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong>.<br />

a) Open a command line (shortcut on desktop) and go to:<br />

c:\<strong>IBM</strong>\websphere\wp_profile\bin<br />

b) Enter the command:<br />

stopServer.bat <strong><strong>Web</strong>Sphere</strong>_<strong>Portal</strong> -username wpsadmin -password<br />

wpsadmin<br />

c) When it is finished stopping, enter the command:<br />

startServer.bat <strong><strong>Web</strong>Sphere</strong>_<strong>Portal</strong><br />

10. Open the theme template located on <strong>Web</strong>DAV at:<br />

dav:fs-type1/themes/labTheme/nls/theme_en.html<br />

11. Directly beneath the element in the theme template:<br />

<br />

Add this line of code to include the dynamic-content spot:<br />

<br />

12. Clear the browser cache and navigate to a page in <strong>Portal</strong> that has the “Lab Theme” defined; the<br />

new dynamic-content spot should render the page ID at the top left-hand corner (see figure 95).<br />

Learn more about working with “Dynamic content spots.”<br />

40


Figure 95. Page ID<br />

5 Theme optimization<br />

The module framework allows extensions to contribute to different areas of the page to provide<br />

flexibility, enhance the user <strong>experience</strong>, and maximize performance.<br />

The intention of the theme modularization framework is to decouple feature enablement from the<br />

theme code itself. This allows themes to be developed more easily from an outside-in approach with<br />

little knowledge about the details of how underlying code for a particular feature in <strong>Portal</strong> works.<br />

The framework provides logical points where modules can contribute data into a theme at runtime<br />

and optimize those contributions by combining them where possible. This allows multiple disparate<br />

remote sources to be combined into one request for greater performance out of the box.<br />

It also provides a way to enable and disable features of a theme by means of configuration, through a<br />

simple module inclusion profile. Theme developers can spend their time focusing on the interface<br />

design of the theme itself without worrying about the details of how to get <strong>Portal</strong> features to work<br />

correctly within their theme. It also provides them an easy way of turning off features they do not need<br />

in one environment that they may use in another environment.<br />

A classic use case for this feature is the ability to disable editing capabilities in a production <strong>Portal</strong><br />

environment while enabling them in a development <strong>Portal</strong> environment. The exact same theme code<br />

can be used across such environments where the only variable is the module inclusion profile.<br />

Developers can provide modules registering extensions and can then consume them by a module<br />

inclusion profile, enumerating the modules by its unique identifier. Modules may prereq other modules<br />

to allow automatic inclusion of necessary code required to make a particular feature work.<br />

Probably the most basic example of this in <strong>Portal</strong> today is the use of Dojo within a module. A <strong>Portal</strong><br />

module may use Dojo to build custom widgets; however, to separate the module's code from Dojo's<br />

code, that module would prereq the necessary Dojo module(s) required to ensure that the necessary<br />

prerequisite code is loaded in the correct sequence.<br />

This allows greater serviceability by decoupling the packaging of the code for each module.<br />

5.1 Setting the theme profile<br />

The <strong>Portal</strong> <strong>7.0.0.2</strong> theme is shipped with three profiles out of the box:<br />

• Lightweight. This profile includes the minimal modules required to render a portlet on a page.<br />

• Full. This profile includes all modules rendered at page initialization, essentially the same amount<br />

of functionality that was seen in previous themes.<br />

• Deferred: This is the default profile set on the <strong>Portal</strong> <strong>7.0.0.2</strong> theme. It loads the same modules<br />

41


as the lightweight profile in View mode, but when entering Edit mode or opening the Actions<br />

menu, it will load the deferred modules as well.<br />

You set the default theme profile by using theme metadata key “resourceaggregation.profile”:<br />

<br />

You have the ability to override the profile set for the theme on a per-page basis, using page<br />

metadata. The profiles are located on <strong>Web</strong>DAV at this location:<br />

dav:fs-type1/themes/labTheme/profiles<br />

Setting a profile on a page<br />

1. Navigate to a page or create a page with the Lab Theme applied.<br />

2. Open the Actions menu and select Edit Page Properties (see figure 96).<br />

Figure 96. Edit Page Properties option<br />

3. Expand the Advanced Properties section (see figure 97).<br />

42


Figure 97. Advanced Properties expanded<br />

4. Select the “I want to set parameters” option and create a parameter with the name<br />

“resourceaggregation.profile” and the value “profiles/profile_lightweight.json” (see figure 98).<br />

Figure 98. Create parameter<br />

5. Click Add, to add the new parameter; click OK, to exit the parameters screen; and then click OK<br />

again, to save the Page Properties.<br />

6. The page now has the lightweight profile applied; notice that the page mode toggle is not<br />

included on the page, and the actions menu has fewer items (see figure 99).<br />

Figure 99. Default profile on the left vs. the lightweight profile on the right<br />

Setting the default theme profile<br />

If you want to change the default profile for a theme, change the page metadata. For this exercise we<br />

change the default profile for the Lab Theme:<br />

43


1. Connect to the themelist entry point on <strong>Web</strong>DAV:<br />

http://localhost:10039/wps/mycontenthandler/dav/themelist/<br />

2. Open the labTheme folder and copy the metadata.properties file to <strong>your</strong> local drive. Edit the local<br />

copy of the file and modify it to point to a different profile; for this exercise we use the lightweight<br />

profile:<br />

resourceaggregation.profile=profiles/profile_lightweight.json<br />

3. Copy the metadata.properties file back into the labTheme folder on <strong>Web</strong>DAV.<br />

4. Navigate to any page created with the labTheme; it will have the lightweight profile applied. Note<br />

that the page mode toggle is not included on the page, and the Actions menu has fewer items.<br />

To Learn more, refer to “Changing the theme profile”.<br />

5.2 Create a custom profile<br />

1. Connect to the fs-type1 <strong>Web</strong>DAV entry point:<br />

http://localhost:10039/wps/mycontenthandler/dav/fs-type1/<br />

2. Go to the profiles folder for the labTheme, dav:fs-type1/themes/labTheme/profile/<br />

3. Copy the profile_full.json file to the local machine and rename it “profile_custom.json.”<br />

4. Open profile_custom.json; you will see all the modules defined for this profile.<br />

5. Find the page sharing module (the ID is mm_page_sharing) and remove it from the profile by<br />

simply removing the line, "mm_page_sharing",<br />

6. Save the file and copy it back to the profiles folder on <strong>Web</strong>DAV.<br />

7. At this point the profile is ready to use; to see the updated profile, apply the profile to a page with<br />

the Lab Theme applied (see Section 4.1 above).<br />

8. After the profile is applied to a page, open the Actions menu. You see that the page sharing<br />

options have been removed from the menu (see figure 100).<br />

Figure 100. Full profile on the left vs. custom profile with sharing removed on the right<br />

44


5.3 Create a custom module<br />

1. Create a new file called newModule.json, which will be a theme-specific module, and copy the<br />

code in listing 5 into it. This defines the new module.<br />

Listing 5. Code to copy into newModule.json<br />

{<br />

"modules":[{<br />

"id":"new_module",<br />

"contributions":[{<br />

"type":"config",<br />

"sub-contributions":[{<br />

"type":"js",<br />

"uris":[{<br />

"value":"/js/new.js"<br />

}]<br />

}]<br />

}]<br />

}]<br />

}<br />

where the “id” is new_module and has only one resource contribution. This is a “config” type<br />

contribution, meaning that it will be placed in the combined dynamic content spot “co:config”,<br />

which can be found in the theme template. The resource we are contributing to the page is a<br />

JavaScript file, which is located on <strong>Web</strong>DAV in the “js” folder of the theme.<br />

2. Create a new file called new.js and place this single line of code into it:<br />

console.log("this is a new module");<br />

The JavaScript here is simple; all it does is display a message to the Firebug console so we<br />

know it is included on the page.<br />

3. Connect to the fs-type1 <strong>Web</strong>DAV entry point:<br />

http://localhost:10039/wps/mycontenthandler/dav/fs-type1/<br />

4. Copy the newModule.json file to the contributions folder for the Lab Theme:<br />

dav:fs-type1/themes/labTheme/contributions/<br />

5. Copy the new.js file to the js folder for the Lab Theme:<br />

dav:fs-type1/themes/labTheme/js/<br />

6. Go to the profiles folder for the Lab Theme:<br />

dav:fs-type1/themes/labTheme/profile/<br />

7. Copy the profile_deferred.json file to the local machine and rename it “profile_new.json”.<br />

8. Open profile_new.json in notepad++ and add the new_module id to the "moduleIDs" definition<br />

(see figure 101).<br />

45


Figure 101. "moduleIDs" definition<br />

9. Copy profile_new.json back to the profiles folder on <strong>Web</strong>DAV. The new module has been defined<br />

and is ready to be applied to a page.<br />

10. Apply the profile_new.json to a Lab Theme page (recall Section 4.1).<br />

11. Open the Firebug console; the console message is displayed (see figure 102).<br />

Figure 102. Console message<br />

You have successfully created a module that contributed a JavaScript file to the page and defined the<br />

new module in a custom profile.<br />

Create a menu item contribution<br />

This exercise reuses the new module created in the first part of this section and adds code so that an<br />

item is added to the Actions menu:<br />

1. Open newModule.json on <strong>your</strong> local machine and add a new sub-contribution to the module<br />

definition for the menu item as shown in listing 6.<br />

Listing 6. New sub-contribution module<br />

{<br />

"type":"menu",<br />

"sub-contributions":[{<br />

"type":"json",<br />

"uris":[{<br />

"value":"/menuDefinitions/newItem.json"<br />

}]<br />

}]<br />

}<br />

46


The entire module definition looks like that shown in figure 103.<br />

Figure 103. Entire module definition<br />

2. Copy newModule.json to the contributions folder on <strong>Web</strong>DAV for the Lab theme:<br />

dav:fs-type1/themes/labTheme/contributions/<br />

3. Open new.js on <strong>your</strong> local machine and add the following code to the end of new.js:<br />

var newModuleShout = function(){<br />

alert("You clicked on the new menu item");<br />

};<br />

The new.js will now have the console statement and this function defined.<br />

4. Copy new.js to the js folder on <strong>Web</strong>DAV for the Lab theme:<br />

dav:fs-type1/themes/labTheme/js/<br />

5. Create a file named newItem.json and copy the code in listing 7 into it:<br />

Listing 7. Code to copy into newItem.json<br />

[{"type":"Separator"},{<br />

"type":"Header",<br />

"titles":[{<br />

"value":"New",<br />

47


"lang":"en"<br />

}]<br />

},{<br />

"type":"StaticMenuitem",<br />

"id":"new_module",<br />

"actionFn":"newModuleShout",<br />

"titles":[{<br />

"value":"Click Me",<br />

"lang":"en"<br />

}]<br />

}]<br />

This code is a JSON menu contribution and defines a menu separator, a new menu heading titled<br />

“New”, and a menu item titled “Click Me” that will display a message.<br />

6. Copy newItem.json to the menuDefinitions folder for the Lab Theme:<br />

dav:fs-type1/themes/labTheme/menuDefinitions/<br />

7. Copy pageActions.json to <strong>your</strong> local machine:<br />

dav:fs-type1/themes/labTheme/menuDefinitions/pageActions.json<br />

8. Reference the new_module in the page actions JSON definition so it will add the menu<br />

contribution; it will be at the end of the file like this:<br />

,{<br />

"type":"ModuleRef",<br />

"id":"new_module"<br />

}]<br />

Be careful to add the comma before a new page action item, and note also that the bracket ] is<br />

the last character in the file, so make sure what is shown here is truly the end of the file, and do<br />

not duplicate brackets.<br />

9. Copy pageActions.json back to the menuDefinitions folder on <strong>Web</strong>DAV for the LabTheme.<br />

10. Clear browser cache, refresh the page with the profile_new.json applied, and open the Actions<br />

menu.<br />

11. Notice the new menu item on which you can click and receive a message (see figure 104).<br />

48


Figure 104. New Click Me menu item<br />

To learn more, refer to “Modules”.<br />

6 Debugging<br />

6.1 Theme optimization debugging<br />

With the new theme optimization framework combining resources and requests, it makes it difficult to<br />

know where an error occurs. There is a simple process you can perform to load resources from their<br />

actual location, to see where the errors are originating.<br />

To enable debugging for theme optimization, follow these steps:<br />

1. Log in to <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong>, using “wpsadmin” for both the username and password.<br />

2. Navigate to Administration --- Enable Tracing and set the following trace string (see figure 105):<br />

com.ibm.wps.resourceaggregator.CombinerDataSource.RemoteDebug=all<br />

49


Figure 105. Enable Tracing window<br />

3. Click OK, go back to a page with the “Lab Theme” (or <strong>Portal</strong> <strong>7.0.0.2</strong> theme) applied, and click the<br />

Actions menu.<br />

4. Open Firebug and view the JavaScript loaded on the page, using the Script panel. Notice that the<br />

modules are loaded using separate links and script tags, isolating each one independently. It also<br />

loads debug versions of each contribution, if the module definition has defined a debug version.<br />

Typically, the debug version is an uncompressed version of the script tag containing the same<br />

data as the normal version (see figure 106).<br />

50


Figure 106. Uncompressed file versions<br />

When you use the Firebug inspector tool to look at the logo, you notice that the CSS file location is<br />

not a combiner resource, but an actual CSS file (see figure 107).<br />

51


Figure 107. CSS file directly named<br />

Using both separate links and uncompressed script tags makes it easier to debug a running <strong>Portal</strong><br />

environment from the browser. This debugging for theme optimization is enabled for all users. To<br />

learn more, refer to “Debugging.”<br />

6.2 Development mode<br />

Usually the profiles and contributions are determined once, when the <strong>Portal</strong> server is started, and<br />

then they are used unchanged. For performance reasons, updates to the system are not included<br />

until a server restart occurs. By enabling development mode, we can see the changes immediately,<br />

and during this exercise development mode was already enabled.<br />

For future development efforts you can enable development mode by setting the<br />

resourceaggregation.development.mode property to “true” within the WP ConfigService REP (found<br />

in the WAS console via Resources --- Resource Environment --- Resource Environment Providers.)<br />

7 Conclusion<br />

You should now be familiar with the concepts of theme architecture, usage, and customization. Using<br />

<strong>Web</strong>DAV, you can easily create new themes and skins along with the components such as styles and<br />

layouts. This paper also discussed the new theme optimization features that can be used to easily<br />

add and remove theme aspects to create a customized <strong>Web</strong> <strong>experience</strong> and increase performance.<br />

8 Resources<br />

Developing Themes for <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong>:<br />

http://www-10.lotus.com/ldd/portalwiki.nsf/xpViewCategories.xsp?lookupName=Developing%20an<br />

%20Exceptional%20<strong>Web</strong>%20Experience<br />

<strong>IBM</strong> <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> Family wiki:<br />

http://www-10.lotus.com/ldd/portalwiki.nsf<br />

<strong>IBM</strong> <strong>Portal</strong> and Lotus <strong>Web</strong> Content Management product documentation:<br />

http://www.ibm.com/developerworks/websphere/zones/portal/proddoc.html#v61infocenters<br />

52


developerWorks® <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> zone:<br />

http://www.ibm.com/developerworks/websphere/zones/portal/<br />

developerWorks white paper, “<strong>Customizing</strong> <strong>your</strong> <strong>IBM</strong> <strong><strong>Web</strong>Sphere</strong> <strong>Portal</strong> <strong>Web</strong> <strong>experience</strong> using Page<br />

Builder: A step-by-step guide”:<br />

http://www.ibm.com/developerworks/websphere/zones/portal/proddoc/portaltheme/<br />

9 Author biography<br />

Jon Lidaka is a Front-end Engineer at <strong>IBM</strong>'s Research Triangle Park Development Lab. During his<br />

time in <strong>Portal</strong> development he has primarily contributed to theme development with a focus on<br />

accessibility and globalization, also contributing to components including the administration portlets<br />

and <strong>Web</strong> application integrator. Jon has spoken at multiple <strong>IBM</strong> conferences on user interface design<br />

and optimizing user interfaces for mobile devices.<br />

Trademarks<br />

• developerWorks, <strong>IBM</strong>, and <strong><strong>Web</strong>Sphere</strong> are trademarks or registered trademarks of <strong>IBM</strong> Corporation in the<br />

United States, other countries, or both.<br />

• Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun<br />

Microsystems, Inc. in the United States, other countries, or both.<br />

• Other company, product, or service names may be trademarks or service marks of others.<br />

53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!