Skip Headers
Oracle® WebCenter Framework Tutorial
10g (10.1.3.2.0)

Part Number B31072-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

4 Customizing Your Page

In this lesson you will extend the page created in the previous lesson by adding customizable components to the page and experimenting with ways to affect the component's look and feel. Along the way you will test your page to confirm that your page is developing the way you expect it to.

Figure 4-1 shows how the components on your page will be laid out once you complete this lesson.

Figure 4-1 MyPage.jspx at the End of Lesson 4

Chapter Overview
Description of "Figure 4-1 MyPage.jspx at the End of Lesson 4"

Introduction

We will customize the page by completing the following steps:

Let's begin by examining some of the benefits that Oracle WebCenter Framework provides.

Step 1: Allowing Users To Customize the Page

One of the key features of Oracle WebCenter Framework is the concept of "Design Time at Run Time", which allows site administrators to customize the page for others. Customization is achieved through customizable components, specifically PanelCustomizable and ShowDetailFrame. (Customizing pages is different from customizing portlets, which you did using portlet actions in the last chapter.)

Using these two components, you can give users the option of hiding a certain piece of content, or moving it to a different location on the page. Let's see how this works.

  1. Make sure MyPage.jspx appears in the Visual Editor.

  2. Open the Component Palette.

  3. Using the drop-down list, select Customizable Components Core (Figure 4-2).

    Figure 4-2 Customizable Components Core

    Customizable Components Core in the Component Palette
    Description of "Figure 4-2 Customizable Components Core"

    There are two items in this group:

    • PanelCustomizable, which provides a horizontal or vertical layout in which to include Oracle ADF components. By setting a few attributes in the Property Inspector, you can enable actions for showing or hiding whatever content is placed within the layout.

    • ShowDetailFrame, through which you can display the actions allowed for a particular component. In this release of Oracle WebCenter Framework, users can move, minimize, or maximize content. You can think of ShowDetailFrame as the chrome, or border that goes around the components on the page.

    Let's see these concepts in action.

  4. In the Applications Navigator, highlight MyPage.jspx.

    Notice how the structure of the page appears in the Structure window (Figure 4-3).

    Figure 4-3 Structure of MyPage.jspx

    Structure of MyPage
    Description of "Figure 4-3 Structure of MyPage.jspx"

  5. In the Component Palette, highlight PanelCustomizable, and drag it to the Structure window. Drop it over the h:form tag.

    Tip:

    When you drop a component inside a form, make sure that h:form has a box around it.

    Working with the Structure view provides greater certainty where a component is being placed but you can also drag and drop components directly onto the Visual Editor.

  6. In the Component Palette, highlight ShowDetailFrame, and drag it to the Structure window. Drop it over cust:panelCustomizable.

    cust:showDetailFrame becomes a child of cust:panelCustomizable, as shown in Figure 4-4.

    Figure 4-4 Hierarchy in Structure Window

    Hiearchy in Structure window
    Description of "Figure 4-4 Hierarchy in Structure Window"

    In the Visual Editor (shown in Figure 4-5), you can see showDetailFrame1 within a grey box. The grey box indicates the cust:panelCustomizable, so we know that we safely dropped showDetailFrame within it. The area that is circled represents the control that users will use to customize the content of showDetailFrame.

    Figure 4-5 ShowDetailFrame Component Added to MyPage.jspx

    ShowDetailFrame component
    Description of "Figure 4-5 ShowDetailFrame Component Added to MyPage.jspx"

    Let's add some content now, in the form of a simple image.

  7. In the Component Palette drop-down list, select ADF Faces Core.

    This presents you with a list of commonly used ADF components.

  8. Scroll down the alphabetical list until you see the ObjectImage component.

  9. Highlight ObjectImage, and drag it to the Structure window. Drop it on top of cust:showDetailFrame.

    The Insert ObjectImage window opens.

  10. Use the ... button to locate the directory where you unzipped webcentertutorialcontent.zip (see Downloading Sample Tutorial Files). For example: C:\TutorialContent

  11. Highlight the image camera.gif, and click OK.

    A dialog opens asking you if you want to locate the image under the document root. If you choose Yes, a copy of the image is saved to a location that is automatically included when you create the application deployment archive.

  12. Click Yes.

  13. Click Save, then OK.

    Figure 4-6 Adding an Image to MyPage.jspx

    Adding an image to MyPage.jspx
    Description of "Figure 4-6 Adding an Image to MyPage.jspx"

    The image camera.gif appears inside the showDetailFrame component as shown in Figure 4-6.

    Tip:

    You can drag and drop images directly from your file system, for example C:\TutorialContent\camera.gif, onto a ShowDetailFrame component. An ObjectImage is created automatically, and the image is copied to the project.

    Let's add another image so you can see how users will be able to move the images around the page.

  14. In the Component Palette drop-down list, select Customizable Components Core, and select ShowDetailFrame.

  15. Drag ShowDetailFrame to the Structure window and drop it on cust:panelCustomizable.

  16. In the Component Palette drop-down list, select ADF Faces Core, and select ObjectImage.

  17. Drag ObjectImage to the Structure window. Drop it on top of the second cust:showDetailFrame.

  18. Use the ... button to locate hula.gif (see Downloading Sample Tutorial Files), and click OK.

    A dialog opens asking you if you want to locate the image under the document root.

  19. Choose Yes.

  20. Click Save, then OK.

    The Design tab in the Visual Editor should now look something like Figure 4-7.

    Figure 4-7 Two Images and a Portlet on MyPage.jspx

    Two images on MyPage.jspx
    Description of "Figure 4-7 Two Images and a Portlet on MyPage.jspx"

    Each image has its own actions icon on the showDetailFrame header, so each can be acted upon independently.

    Now let's run the page and see what kind of customizations are possible.

Step 2: Running and Customizing the Page

In this step, we run the page and test the customizations that a user might make.

  1. Right-click MyPage.jspx, and click Run.

    Assuming there aren't any compiler errors, the page opens in another browser window, as shown in Figure 4-8.

    Figure 4-8 MyPage.jspx with Two Images

    MyPage.jspx with two images
    Description of "Figure 4-8 MyPage.jspx with Two Images"

  2. Click the Actions icon on the first image.

    You should see two actions: Move and Maximize as shown in Figure 4-9.

    These actions are automatically provided by showDetailFrame. Any components you drop within a showDetailFrame can be moved or maximized within the context of its parent panelCustomizable.

  3. Click Maximize in the first image and see how its showDetailFrame expands to fill the entire panelCustomizable as shown in Figure 4-10. The second image is hidden.

    Notice that MyJavaPortlet is unaffected by this action. That's because the portlet is not part of this panelCustomizable.

    Figure 4-10 One Image Maximized

    One image maximized
    Description of "Figure 4-10 One Image Maximized"

  4. Click the Actions menu, and then click Restore to return the image to its original size.

  5. On either of the images, click Move, Down or Move, Up to see the images switch places on the page. Again, because MyJavaPortlet is not controlled by this panelCustomizable, it remains stationary as the images trade places.

    Figure 4-11 shows the browser after Move, Down was used on the first graphic, the camera. The hula graphic is now on top of the camera graphic.

    Figure 4-11 Moving Images Around

    Moving images around
    Description of "Figure 4-11 Moving Images Around"

In the next step, we'll move MyJavaPortlet into cust:panelCustomizable, and experiment with the Property Inspector to affect the behavior of different components on the page.

Step 3: Making Additional Customizations

  1. Close the browser, and return to JDeveloper.

  2. In the Structure window, drag adfp:portlet, which represents MyJavaPortlet, and drop it on cust:panelCustomizable (Figure 4-12).

    Figure 4-12 Dropping the Portlet Onto PanelCustomizable

    Dropping the portlet onto panel:customizable
    Description of "Figure 4-12 Dropping the Portlet Onto PanelCustomizable"

    The portlet automatically goes to the bottom of the list of objects, and the Design view follows suit. The portlet now appears beneath the second image.

    Notice that we dropped the portlet directly onto cust:panelCustomizable without inserting a showDetailFrame first. That's because the portlet comes automatically equipped with the customization capabilities provided by the portlet chrome; that is, the ability to maximize/minimize and to reposition the portlet on the page.

    Now let's choose a different orientation for the portlet and images. Rather than displaying them vertically, let's display them horizontally.

  3. In the Structure window, highlight cust:panelCustomizable.

  4. In the Property Inspector, under General, click the field beside Layout.

    The Property Inspector is to the right of your JDeveloper screen (Figure 4-13).

    Figure 4-13 JDeveloper Property Inspector

    Property Inspector location
    Description of "Figure 4-13 JDeveloper Property Inspector"

  5. Select horizontal as shown in Figure 4-14.

    Figure 4-14 Selecting a Horizontal Layout

    Selecting a horizontal layout
    Description of "Figure 4-14 Selecting a Horizontal Layout"

    You can see in the Visual Editor that the portlets and images are now side by side, rather than on top of one another as seen in Figure 4-15.

    Figure 4-15 Horizontal Layout View

    Horizontal layout view
    Description of "Figure 4-15 Horizontal Layout View"

    Now let's activate the ability to hide or show content.

  6. In the Property Inspector, under General, locate DisplayHeader, and change it to true as shown in Figure 4-16.

    Figure 4-16 Changing DisplayHeader to True

    Changing DisplayHeader to true
    Description of "Figure 4-16 Changing DisplayHeader to True"

    This displays a header area at the top of the layout so that there is room for the Action icon to appear as part of the menu. (If for some reason you don't want to display the header in your own applications, you can keep DisplayHeader set to false. As long as you complete the next step, the menu actions for the component are displayed by hovering over the panelCustomizable area.)

  7. In the Property Inspector, under Actions, locate IsSeededInteractionAvailable, and change it to true.

    The IsSeededInteractionAvailable attribute makes it possible to display whatever menu actions are supported by the component. In this case, the user will be able to hide or show any content that appears within the layout.

    Now let's change the name of MyJavaPortlet through the Property Inspector, just so you can see how it's done.

    Note that once you make changes through the Property Inspector, you can never again customize or personalize the portlet's name at runtime. Although this behavior is acceptable for the purposes of this tutorial, it's something you'll want to keep in mind as you develop your own applications in the future.

  8. In the Structure window, highlight adfp:portlet so that the Property Inspector now reflects the portlet's properties.

  9. In the Property Inspector, under General, locate the Text field, and enter: Sample Portlet as shown in Figure 4-17.

    This changes the name that appears in the portlet header.

    Figure 4-17 Renaming the Portlet

    Renaming the portlet
    Description of "Figure 4-17 Renaming the Portlet "

  10. Click Save All in the JDeveloper toolbar.

Let's run the page again to see how these changes affect the page.

Step 4: Testing the New Customizations

To test the customizations, we run the page and make sure it looks as we expect it to:

  1. Before running the page again, stop the embedded OC4J Server. Choose Run, Terminate, Embedded OC4J Server from the main menu.

    Alternatively, click the red square Terminate icon in the Embedded OC4J Server Log window.

  2. Click MyPage.jspx in the Visual Editor, then click the green arrow in the toolbar to run the page.

    Assuming there aren't any compiler errors, the page opens in a new browser window (Figure 4-18).

    Figure 4-18 panelCustomizable with Two showDetailFrames and a Portlet

    panelCustomizable with two showDetailFrames
    Description of "Figure 4-18 panelCustomizable with Two showDetailFrames and a Portlet"

  3. As a result of activating IsSeededInteractionAvailable, the container object's Action icon now contains a Show Content action, through which you can hide or show the images and portlet (Figure 4-19). Take a moment now to experiment with them.

    Figure 4-19 Show Content Action

    Show Content action
    Description of "Figure 4-19 Show Content Action"

    All the other page customizations we made in Step 3 are also there:

    • The title of the portlet has changed to Sample Portlet. Now that the portlet title is driven by the Text property you can no longer customize or personalize the title at runtime. If you click the Actions icon and choose Customize, you'll see this for yourself.

    • The components are displayed horizontally, instead of vertically. If you click the Actions icon on one of the images, you can see that the Move action now says Left and Right instead of Up and Down.

    • Because we changed DisplayHeader to true, the container object, panelCustomizable, now displays a header area. Recall that the layout had no such header in Step 3, before we changed the DisplayHeader setting.

    Everyone who runs the page will see these page customizations.

  4. Before moving on, let's remove the permanent portlet title customization we made through the Property Inspector. In Chapter 8, "Providing Security" we use the portlet's title property to demonstrate page personalization so we must be able to change the name at runtime:

    1. Close the browser, and return to JDeveloper.

    2. In the Structure Window for MyPage.jpsx, highlight adfp:portlet.

    3. In the Property Inspector, click the Text field, and then click the Reset to Default icon in the Property Inspector toolbar. This will remove the text Sample Portlet.

      In the Visual Editor, the name in the portlet header should change back to MyJavaPortlet1.

In the future, you may want to use multiple panelCustomizable components on a page, each containing one or more portlets or objects within a showDetailFrame component. Because each layout has its own Move, Maximize, and Show/Hide capabilities, placing multiple layouts on the page enables you to treat blocks of components and portlets as separate entities. You'll find more information in the Oracle WebCenter Framework Developer's Guide.

Step 5: Changing the Look and Feel

In Oracle WebCenter Framework, there are two ways to control the style (that is, look and feel) of your application:

In the following steps, you'll use both of these methods to change the look and feel of MyPage.jspx:

Step 5a: Changing showDetailFrame Background Using the Default ADF Faces Skin

In this step, you'll use the default ADF Faces skin (called Oracle) to influence style-related properties.

  1. In the Structure window, highlight one of the cust:showDetailFrame entries. We'll use this component to see how to specify style property values.

  2. In the Property Inspector, expand the Background property.

    The default ADF Faces skin offers three settings, light, medium, and dark. Let's choose a dark background for this component.

  3. Change the value to dark, as shown in Figure 4-20.

    Figure 4-20 Property Inspector: Background

    Available border styles
    Description of "Figure 4-20 Property Inspector: Background"

  4. Click File, Save All to save your work.

  5. Click the red square to stop the embedded OC4J in preparation to run your page again.

  6. Right-click MyPage.jspx, and click Run.

    Assuming there aren't any compiler errors, the page opens in a new browser window (Figure 4-21). Notice how the background decoration of the showDetailFrame has changed.

    Figure 4-21 Image with Dark Background

    Image with border color
    Description of "Figure 4-21 Image with Dark Background"

    Now let's see how to create a brand new skin and override the styles defined by the default ADF Faces skin.

Step 5b: Using Custom Skins to Apply Your Own Styles

In this step you'll create a new skin, register the skin with your application, and learn how to apply custom styles to components on MyPage.

  1. First, return to JDeveloper and create a brand new style sheet (.css):

    1. In the Applications Navigator, right-click ViewController, and choose New.

    2. In the New Gallery under Categories, expand the Web Tier, and select HTML.

    3. Under Items, select CSS File, and click OK.

    4. For File Name, enter mystyle.css as shown in Figure 4-22.

      Figure 4-22 Create Cascading Style Sheet

      Image with border color
      Description of "Figure 4-22 Create Cascading Style Sheet"

    5. Click OK.

    Your new style sheet appears in the Applications Navigator under ViewController, Web Content, css and also displays in the Editor. Notice the default style selectors BODY, H1, H2, and H3.

    In the steps that follow, you'll register a new skin with your application. This involves creating a file named adf-faces-skins.xml, and populating it with a short list of tags that identify the skin's ID, location, .css, and the like.

  2. Let's create adf-faces-skins.xml:

    1. In the Applications Navigator, under ViewController, Web Content, right click the WEB-INF folder, and select New.

    2. In the New Gallery, set the Filter By scope to All Technologies.

    3. Under the General node, select XML.

    4. In the right pane, select XML Document, and click OK.

    5. In the File Name field, enter the file name: adf-faces-skins.xml as shown in Figure 4-23.

      Figure 4-23 Create adf-faces-skins.xml

      Image with border color
      Description of "Figure 4-23 Create adf-faces-skins.xml"

    6. The file must be stored in the WEB-INF folder, so just click OK to create the file.

      An empty XML file displays in the Editor. It appears in the Applications Navigator under WEB-INF.

  3. Add tags to adf-faces-skins.xml to identify your new skin (and point to your new style sheet mystyle.css):

    1. Copy and paste the following code into the XML Editor:

      <?xml version="1.0" encoding="ISO-8859-1"?>
      <skins xmlns="http://xmlns.oracle.com/adf/view/faces/skin">
       <skin>
        <id>mystyle</id>
        <family>mystyle</family>
        <render-kit-id>oracle.adf.desktop</render-kit-id>
        <style-sheet-name>css/mystyle.css</style-sheet-name>
       </skin>
      </skins>
      
      

      Your file should look Figure 4-24.

      Figure 4-24 Configure adf-faces-skins.xml

      Image with border color
      Description of "Figure 4-24 Configure adf-faces-skins.xml"

    2. Click File, Save to save adf-faces-skins.xml.

    In the next step you'll configure your application to use this new skin by setting the <skin-family> tag in adf-faces-config.xml.

  4. Edit the <skin-family> tag in adf-faces-config.xml:

    1. Open adf-faces-config.xml, located under ViewController, Web Content, WEB-INF.

    2. Replace oracle (the default skin) with the family name of your new skin. Enter mystyle as shown in Figure 4-25.

      Figure 4-25 Edit Skin Family in adf-faces-config.xml

      Image with border color
      Description of "Figure 4-25 Edit Skin Family in adf-faces-config.xml "

    3. Click File, Save.

    Now the new skin is registered with your application, let's add some style selectors to your style sheet that apply to showDetailFrame components on MyPage.

  5. Add the following style selectors to mystyle.css:

    1. In the Applications Navigator, under ViewController, Web Content, css, double-click mystyle.css.

    2. Copy the following code, and paste it at the bottom of the file:

      af|showDetailFrame::header-light
      {
       color:Purple;
      }
      af|showDetailFrame::header-medium
      {
       color:Purple;
      }
      af|showDetailFrame::header-dark
      {
       color:White;
      }
      
      

      This code specifies the color for the text that displays in a showDetailFrame component's header and a portlet's header. We've chosen purple text for header-light and header-medium, and white text for header-dark. Choose another color scheme if you prefer.

    3. Copy the following code, and paste it at the bottom of the file:

      af|showDetailFrame::content-light, af|showDetailFrame::content-medium, af|showDetailFrame::content-dark
      {
       color: Black;
       background-color: Silver;
       border-left:1px black solid;
       border-right:1px black solid;
       border-bottom:1px black solid;
      }
      
      

      This code changes the content of a showDetailFrame and portlet body to have a silver background, with black text and black borders. Choose another color scheme if you prefer.

    For a full list of style selectors for showDetailFrame and panelCustomizable components, see Oracle WebCenter Framework Developer's Guide.

  6. Now change the background color of your page. Scroll to the BODY tag at the top of the style sheet, and change the background-color from White to Purple. The BODY tag should look like this:

    BODY
    {
       background-color: Purple;
       color: black;
       font-family: Arial, Helvetica, sans-serif;
    }
    
    
  7. Click File, Save All to save your work.

  8. Click the red square to stop the embedded OC4J in preparation to run your page again.

  9. Right-click MyPage.jspx, and click Run.

    Assuming there aren't any compiler errors, the page opens in a new browser window.

    Take a moment to examine the new look and feel. If you used the styles we suggested your page will look like Figure 4-26. Notice how showDetailFrames display purple/white header text, black content text, and have a silver background. The background of the page will be colored purple too.

    Figure 4-26 MyPage.jspx Using mystyle.css

    Image with border color
    Description of "Figure 4-26 MyPage.jspx Using mystyle.css"

    During this lesson you've experimented with ways to affect the look and feel of your application. You'll find more detailed information in the Oracle WebCenter Framework Developer's Guide.

    Before moving on, let's change back to the default Oracle skin.

  10. To remove the custom skin:

    1. Open adf-faces-config.xml, located under ViewController, Web Content, WEB-INF.

    2. Change the <skin-family> tag back to oracle as shown in Figure 4-27.

      Figure 4-27 Edit Skin Family in adf-faces-config.xml

      Image with border color
      Description of "Figure 4-27 Edit Skin Family in adf-faces-config.xml "

    3. Click File, Save All.

In the next lesson, you'll learn how to add the Rich Text portlet, which provides a bulletin board-like feature to users.