Skip Headers
Oracle® Fusion Middleware Skin Editor User's Guide for Oracle Application Development Framework
11g Release 2 (11.1.2.0.0)

Part Number E17456-02
Go to Documentation Home
Home
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

8 Working With Global Selector Aliases

This chapter describes how to work with global selector aliases.

This chapter includes the following sections:

8.1 About Global Selector Aliases

A global selector alias defines style properties in one location in the ADF skin that you can apply to multiple ADF Faces and ADF Data Visualization components. A global selector alias may also be referred to as a selector alias, or simply a selector. The ADF skins provided by Oracle ADF, described in Section 1.4, "Inheritance Relationship of the ADF Skins Provided by Oracle ADF" and Section 11.4, "ADF Skins Provided by Oracle ADF" make extensive use of global selector aliases to define common style properties for text, messages, icons, colors and different groups of components. Many component-specific selectors inherit the styles defined for these global selector aliases. For example, the.AFDefaultFontFamily:alias global selector alias defines a default font family for all ADF Faces components in your application that display text. Any ADF skin that you create by extending from one of the ADF skins provided by Oracle ADF inherits the properties defined in the .AFDefaultFontFamily:alias global selector alias. Figure 8-1 shows how the visual editor displays that the af|commandButton selector inherits the value for font family from the.AFDefaultFontFamily:alias global selector alias.

Figure 8-1 Component Selector Inheriting Value from Global Selector Alias

Component Selector Inheriting from Global Selector Alias

Figure 8-1 also shows the different categories of global selector aliases. Each category groups global selector aliases according to their purpose:

For detailed descriptions of the global selector aliases, see the Oracle Fusion Middleware Tag Reference for Oracle ADF Faces Skin Selectors. Global selector aliases that you define appear under the Global Selector Aliases node, as shown by the entry for the .UserDefined:alias in Figure 8-1.

The View as list displays the list of components that reference a global selector alias when you select a global selector alias in the Selector Tree. In Figure 8-2, the user selected Panel Window from the list because the panelWindow component references the global selector alias.

Note:

Sometimes components appear in the View as list for which the style properties defined in the global selector alias do not render in the component. This may be because the component initially referenced the global selector alias in an extended ADF skin and your ADF skin overrides the global selector alias for that component. Alternatively, it may be because the component itself overrides the global selector alias using one of its style-related attributes (styleClass or inlineStyle).

In Figure 8-2, the user has changed the inherited value for the .AFDefaultFontFamily:alias global selector alias and viewed the resulting change as it applies to the panelWindow component. All selectors that inherit the value of the .AFDefaultFontFamily:alias global selector alias will render at runtime using the font family defined in the ADF skin. For example, both the dialog and panelWindow components render using this font family.

Figure 8-2 ADF Skin Changing a Global Selector Alias

ADF Skin Changing a Global Selector Alias

In addition to the global selector aliases already described, a number of component selectors define selector aliases that are specific to these components only. These selector aliases appear under the nodes for the component selectors in the Selector Tree. Figure 8-3 shows examples from a number of the component selectors that expose these types of selector aliases.

Figure 8-3 Component Selector Aliases

Component Selector Alias

8.2 Creating a Global Selector Alias

You can create a global selector alias to define in one location the style properties that you want a number of selectors to reference. You enter the name of the new global selector alias in the Create Alias Selector dialog. The ADF Skin Editor appends the keyword :alias and prepends . to the name that you enter in the dialog. For example, if you enter myGlobalSelector as the name in the dialog, the resulting name that appears in the user interface and in the source file of the ADF skin is:

.myGlobalSelector:alias

The keyword :alias identifies your global selector alias as a CSS pseudo-class and serves as a syntax aid to organize the CSS code in the source file of your ADF skin.

After you create a global selector alias, you modify it to define the style properties that you want it to contain. For more information, see Section 8.3, "Modifying a Global Alias Selector."

8.2.1 How to Create a Global Selector Alias

You can create a global selector alias that defines the style properties that you want a number of user interface components to use.

To create a global selector alias:

  1. In the Selector Tree of the visual editor, select New Alias Selector from the Plus icon's list, as illustrated in Figure 8-4.

    Figure 8-4 New Alias Selector Option in the Selector Tree

    New Alias Selector Option in the Skinning Navigator

    The Create Alias Selector dialog opens.

  2. Enter a name for the global alias selector in the Alias Selector Name field.

    Tip:

    Enter a name for the global alias selector that indicates the purpose it serves. For example, MyLinkHoverColor for a global alias selector that is to change the color of a link when an end user hovers over the link.
  3. Click OK.

  4. In the Property Inspector, set values for the properties that you want to configure in the global selector alias.

8.2.2 What Happens When You Create a Global Alias Selector

The global alias selector appears under the Global Selector Aliases node in the Selector Tree and a visual representation as it applies to a component appears in the Preview Pane, as illustrated in Figure 8-5.

Figure 8-5 Newly-Created Global Alias Selector

Newly-Created Shared Skinning Key

CSS syntax for the global alias selector that you create appears in the source file of the ADF skin. Figure 8-5 shows the entries that appear in the source file of the ADF skin in Figure 8-5.

Example 8-1 CSS Syntax for a Newly-Created Global Alias Selector

.MyLinkHoverColor:alias{
}

8.3 Modifying a Global Alias Selector

You can modify any of the categories of global alias selector described in Section 8.1, "About Global Selector Aliases." Modifying a global selector alias that appears under the Global Selector Aliases node in the Selector Tree when you first create the ADF skin means that you override the inherited style properties defined in the parent ADF skin of your ADF skin. The parent ADF skin is the ADF skin from which your ADF skin extends. You chose the ADF skin from which to extend when you created an ADF skin, as described in Section 4.4, "Creating an ADF Skin File." After you modify a global selector alias, the component-specific selectors that inherit the style properties defined in the global selector alias use the modified values.

Modifying a global selector alias that you create in your ADF skin does not override any style properties inherited from the parent ADF skin.

8.3.1 How to Modify a Global Alias Selector

You modify a global alias selector by setting values for it in the Property Inspector. You then verify that the changes you make apply to the component-specific selectors as you intend.

To modify a global selector alias:

  1. In the Selector Tree of the visual editor, select the global selector alias that you want to modify.

    For example, if you want to modify the global selector alias that defines the default font family, select it as illustrated in Figure 8-6.

    Figure 8-6 Modifying a Global Selector Alias

    Modifying a Global Selector Alias
  2. In the Property Inspector, set values for the properties that you want to modify.

  3. In the visual editor, click the View as list to select a component-specific selector that inherits the property values defined in the global selector alias that you have just modified.

  4. In the visual editor, verify that the changes render for the component-specific selector as you intend. Repeat steps 1 to 3 until you achieve the changes you want for the component-specific selectors that inherit from the global selector alias.

8.4 Applying a Global Alias Selector

After you create a global alias selector in your ADF skin, you need to specify the ADF Faces and ADF Data Visualization components that you want to render at runtime using the style properties that you defined in the global alias selector.

Applying a global alias selector to an ADF Faces or ADF Data Visualization component requires you to:

8.4.1 How to Apply a Global Alias Selector

You apply a global alias selector by specifying it as a value for the ADF skin's -tr-rule-ref- property.

To apply a global alias selector:

  1. In the Selector Tree of the visual editor, select the item to which you want to apply the global alias selector.

    For example, select the inputText component's content pseudo-element if you want to apply the style properties defined in your global alias selector to the label for that component, as shown in Figure 8-7.

  2. In the Property Inspector, expand the Common section and then click the Add icon next to the -tr-rule-ref- field.

  3. Enter the name of the global alias selector. Enter the name between quotes that you preface with the selector keyword in the Value field.

    For example, if the name of the global alias selector is .MyBackgroundColor:alias, enter selector(".MyBackgroundColor:alias"), as illustrated in Figure 8-7.

    Figure 8-7 inputText Component's content Pseudo-Element

    Input Text Component's label Skinning Key
  4. Click the Refresh icon in the Preview Pane to view the changes.

8.4.2 What Happens When You Apply a Global Alias Selector

The selector to which you applied the global selector alias inherits the style properties defined in the global selector alias. Figure 8-8 shows the content pseudo-element for the inputText component's selector that inherits the style properties defined in the .MyBackgroundColor:alias global selector alias. The properties that inherit their values from a global selector alias when you specify the global selector alias as a value for the ADF skin -tr-rule-ref property update to use the inheritance icon, as shown for the Background Color and Color fields in Figure 8-8.

At runtime, the inputText component's content area renders using the style properties defined in the global selector alias.

Figure 8-8 Global Selector Alias Applied to inputText Component

placeholder graphic for question above

8.5 Referencing a Property Value from Another Selector

Rather than set a specific style property for each selector to which you want to apply the style property, you can reference the value of a property using the -tr-property-ref ADF skin property. You can configure this ADF skin property for global selector aliases and component-specific selectors. For example, you could define a value for the background-color property in a global selector alias and reference this value from multiple other selectors. If you decide at a later time to change the value of the background-color property, you change the value in the global selector alias. All selectors that reference the background-color property using the -tr-property-ref ADF skin property update to use the change you make. The -tr-property-ref ADF skin property can also be used with compact CSS properties like, for example, border.

8.5.1 How to Reference a Property Value from Another Selector

You reference the property value that you want to use for a selector using the -tr-property-ref ADF skin property.

To reference a property value from another selector:

  1. In the Selector Tree of the visual editor, select the selector that you want to reference a property value from another selector.

    For example, if you want the content area of the panelWindow component to reference a style property defined in another selector, select content under the Pseudo-Elements node of the panelWindow component, as illustrated in Figure 8-9.

    Figure 8-9 Panel Window Component's content Pseudo-Element

    Panel Window Component's content Pseudo-Element
  2. In the Property Inspector, specify the property value that you want to reference as a value for the selector's property using the -tr-property-ref ADF skin property.

    For example, assume that you created the following global selector alias:

    .MyColor:alias {
         color: rgb(255,181,99);
                 font-weight: bold;
    }
    

    and that you want to reference the color property from this global selector alias for the background-color property of the content pseudo-element that you selected in step 1. In this scenario, enter the following value for the background-color property of the content pseudo-element,

    -tr-property-ref(".MyColor:alias","color");
    

    If you want to use the -tr-property-ref in compact values, enter syntax similar to the following:

    border: 10px solid -tr-property-ref(".AFDefaultColor:alias", "color");
    

8.5.2 What Happens When You Reference a Property Value from Another Selector

The Property Inspector shows that the property for which you set a value using the -tr-property-ref ADF skin property to reference a value from another selector inherits its value, as illustrated in Figure 8-10.

Figure 8-10 Selector Property Referencing a Property Value from Another Selector

Property Referencing a Property Value from Another Selector

Syntax similar to Example 8-2 appears in the source file of the ADF skin.

Example 8-2 -tr-property-ref ADF Skin Property

/**ADFFaces_Skin_File / DO NOT REMOVE**/
@namespace af "http://xmlns.oracle.com/adf/faces/rich";
 
@namespace dvt "http://xmlns.oracle.com/dss/adf/faces";
 
.MyColor:alias {
    color: rgb(255, 181, 99);
    font-weight: bold;
}
 
.AFDefaultColor:alias {
    color: Red;
}
 
af|panelWindow::content {
    background-color: -tr-property-ref(".MyColor:alias", "color");
    border: 10px solid -tr-property-ref(".AFDefaultColor:alias", "color");
}