Oracle Fusion Middleware Tag Reference for Oracle ADF Faces 12c (12.2.1.4.0) E81455-03

# <af:toolbar>

af:toolbar toolbar toolbar

UIComponent class: oracle.adf.view.rich.component.rich.layout.RichToolbar
Component type: oracle.adf.RichToolbar

Unsupported agents: pda

A toolbar is a single row container designed to hold buttons and other simple components. Toolbars are not rendered on printable pages.

## Allowed Children

While a toolbar was designed to hold buttons, it can also contain other simple components. But you should be aware that this could cause undesirable changes to its visual appearance. For example, if you include a tall component, the toolbar will be taller to compensate, and other items on the toolbar may no longer align nicely. If you include an overly wide component, it may look weird when that component is forced into overflow. A toolbar can also dynamically add children using a facetRef, iterator, or switcher child.

Please note that you should not nest toolbars, menuBars, or other container-type components inside a toolbar. This is incompatible with overflow and is not supported. If you would like to display multiple toolbars or menuBars in a single row, you should instead use a toolbox group.

## Grouping Items in a Toolbar

If you use an `<af:group>` to group items inside a toolbar, the toolbar will by default include separators around the group. You should also note that the group has an effect on certain items. For example, buttons with type of radio that are grouped together are automatically considered part of the same radio group.

By default visual group separators always appear. If you want a group but do not want the group separator to appear, you can set the group's startBoundary or endBoundary attributes to 'hide' to request that the corresponding boundary be hidden. Note that when a first group's endBoundary and a second group's startBoundary are both set, the separator will only be hidden if both values are set to 'hide' or one value is 'hide' while the other value is 'dontCare'.

## Toolbar Layout

Toolbars were designed to be used inside an `<af:toolbox>`. A toolbox allows highly customizable display of toolbars, by utilizing their flex values and allowing multiple toolbars and menuBars per row.

You may use a toolbar outside of a toolbox, though doing so will cause the toolbar to lose the geometry management functionality that the toolbox provides. Without a toolbox, you cannot have multiple toolbars per row or benefit from flex values.

Because toolbars and toolboxes are overflow components, they do not have a set width size. A toolbar or toolbox should be placed in a section of the page where it can horizontally stretch to the available size for proper rendering. Putting a toolbar or toolbox inside a section of the page where it is horizontally constrained to a minimum size (like a panelStretchLayout end facet) will be error-prone, due to the fact that the width of the toolbar varies with its current overflow state.

## Keyboard Access

Toolbars are designed to use arrow keys to move focus between toolbar items. When buttons and other simple widgets are included on a toolbar, they are no longer individual tabstops. Instead, the toolbar is a single tabstop with the left and right arrow keys being used to access the items on the toolbar. When arrowing beyond the last (or first) toolbar item, the focus is moved to the next (or previous) tab stop outside the toolbar. For items in overflow, the up and down arrow keys also work to move focus.

Some widgets (especially input components) are already using arrow keys for other purposes. For example, inputText uses arrow keys to move cursor inside the input. That makes these components incompatible with the default keyboard paradigm described above. If a toolbar detects that it has children like this, or contains content that it does not recognize, then all children will remain as default tabstops so they can still be accessed by a keyboard only user. Even though we handle this situation, it is less than ideal.

Components that are already responding to arrow keys should either not be placed on a toolbar or be placed on a toolbar by themselves.

## Right Justifying Toolbar Items

By default toolbars are left (start side) justified. In order to make some or all of the toolbar items right (end side) justified, you can use the stretchId attibute. StretchId is usually set to the id of an af:spacer on the toolbar that you want to stretch to take up any available extra horizontal space. The component that you specify must be present on the client. Therefore, if using a component that may not be present on the client (like af:spacer), you should set the child component's clientComponent attribute to 'true'.

### Example of right justifying toolbar items

    <af:toolbox id="tbx1">
      <af:toolbar flex="1" stretchId="stretch1" id="tb1">
        <af:group id="g1">
          <af:button text="Forward"
                     icon="/images/fwdarrow_gray.gif"
                     disabled="true"
                     id="b1"/>
          <af:button icon="/images/uplevel.gif"
                     id="b2"/>
        </af:group>
        <af:button text="Search"
                   icon="/images/search.gif"
                   id="b3"/>
        <af:button text="Folders"
                   icon="/images/folders.gif"
                   id="b4"/>

        <!-- Insert a stretched spacer to push subsequent buttons to the right -->
        <af:spacer id="stretch1" clientComponent="true"/>

        <af:button text="Reports" id="b5"/>
        <af:button text="Refresh:OFF" id="b6"/>
      </af:toolbar>
    </af:toolbox>

## Assigning Percent Width to a Toolbar in a Row

When used inside a toolbox row, you can use a flex value on a toolbar to control what percentage of the available horizontal space that toolbar should receive. For example, if your toolbox row has 3 toolbars, each with a flex value of "1", then they receive their flex value (1) of the total space available (3). This means that each of the three toolbars would be given one third of the available horizontal space.

## Updating through PartialTriggers

Note that if a toolbar child component is going to be updated through partial page rendering, you need to update the toolbar as well. You do this by adding the child components id to the toolbar's partialTriggers attribute. This way the toolbar can appropriately manage its children in respect to sizing and placement in overflow. Also note that many input components also update themselves through partial page rendering. If you include an input component (or quickQuery) on a toolbar, you should include that child's id in the toolbar's partialTriggers attribute so that the toolbar also updates when the input component is replaced. Because this partialTrigger will cause overflow to close during the toolbar ppr, toolbar child components that update themselves via ppr outside of a submit (like InputComboboxLOV) will work better when not in overflow.

## Geometry Management

- This component can be stretched by a parent layout component that stretches its children, e.g. panelStretchLayout, panelSplitter.
- This component accepts buttons and other simple components as children, including spacers and images. Children are not by default stretched. This component also has a stretchId attribute. When this attribute is set to the id of one of its children, that child is stretched.

## Overflow

Toolbar is an overflow component. When a toolbar does not have enough space to display all items, the children are put into overflow and an overflow button is displayed. When a toolbar in a toolbox row has a flex value, the flex value is strictly followed, even in regards to overflow. When toolbars (or menuBars) in a toolbox row do not have flex values, then the right most (end side) toolbar would be forced into overflow before left side toolbars. Spacer and image children on toolbars are not put into overflow.

Overflow components must be part of a supported layout in order to work properly on the page.

An overflow component requires that it is either:

- in a container that stretches its children, or
- in a container that has a set width.

Under these circumstances, when the overflow component is larger than the parent container, the overflow component will display an overflow button. Selecting the overflow button will show a popup containing the items that didn't fit on the page.

Setting up an overflow component with the following layouts is not supported. If you use one of these layouts, you may have unexpected and inconsistent results:

- in a container that does not stretch its children.
- in a container that displays multiple children horizontally without explicit sizes for each child. For example, a panelGroupLayout with layout='horizontal' would be invalid, but panelSplitter is OK because it has an explicitly set splitter position.
- setting the overflow component with a styleClass or inlineStyle that assigns a percentage width value. Note that this includes assigning styleClass='AFStretchWidth' on an overflow component.

## Screen Shot(s)

Toolbar component with 4 button components.

## Code Example(s)

    <af:toolbar id="tb1">
       <af:group id="g1">
          <af:button text="Search" icon="/images/search.gif" id="b1"/>
          <af:button text="Folders" icon="/images/folders.gif" id="b2"/>
       </af:group>
       <af:group id="g2">
          <af:button text="Reports" id="b3"/>
          <af:button text="Refresh:OFF" id="b4"/>
       </af:group>
    </af:toolbar>

## Events

Type | Phases | Description
--- | --- | ---
org.apache.myfaces.trinidad.event.AttributeChangeEvent | Invoke, Application, Apply, Request, Values | Event delivered to describe an attribute change. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change event might include the width of a column that supported client-side resizing.

## Attributes

Name | Type | Supports EL? | Description
attributeChangeListener | javax.el.MethodExpression | Only EL | a method reference to an attribute change listener. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing.
binding | oracle.adf.view.rich.component.rich.layout.RichToolbar | Only EL | an EL reference that will store the component instance on a bean. This can be used to give programmatic access to a component from a backing bean, or to move creation of the component to a backing bean.
clientComponent | boolean | Yes | Default Value: false whether a client-side component will be generated. A component may be generated whether or not this flag is set, but if client Javascript requires the component object, this must be set to true to guarantee the component's presence. Client component objects that are generated today by default may not be present in the future; setting this flag is the only way to guarantee a component's presence, and clients cannot rely on implicit behavior. However, there is a performance cost to setting this flag, so clients should avoid turning on client components unless absolutely necessary. For the components outputText and outputFormatted, setting the clientComponent to true will render id attribute for the html DOM. This ID attribute can alternatively be generated by setting oracle.adf.view.rich.SUPPRESS_IDS to "auto" in web.xml.
customizationId | String | Yes | This attribute is deprecated. The 'id' attribute should be used when applying persistent customizations. This attribute will be removed in the next release.
flex | int | Yes | Default Value: 0 a non-negative integer that indicates the flexibility of this component in its containing toolbox. When in a toolbox, flex is used to determine how horizontal space is distributed among toolbox children in the same row. Components with larger flex values will be assigned more horizontal space than components with lower flex values. This is done using the ratio determined by the flex of each of the child components. The actual value is only relevant if there are other flexible components (components with flex values larger than zero) within the same container.
id | String | No | the identifier for the component. Every component may be named by a component identifier that must conform to the following rules: They must start with a letter (as defined by the Character.isLetter() method) or underscore ( _ ). Subsequent characters must be letters (as defined by the Character.isLetter() method), digits as defined by the Character.isDigit() method, dashes ( - ), or underscores ( _ ). To minimize the size of responses generated by JavaServer Faces, it is recommended that component identifiers be as short as possible. If a component has been given an identifier, it must be unique in the namespace of the closest ancestor to that component that is a NamingContainer (if any).
inlineStyle | String | Yes | the CSS styles to use for this component. This is intended for basic style changes. The inlineStyle is a set of CSS styles that are applied to the root DOM element of the component. Be aware that because of browser CSS precedence rules, CSS rendered on a DOM element takes precedence over external stylesheets like the skin file. Therefore skins will not be able to override what you set on this attribute. If the inlineStyle's CSS properties do not affect the DOM element you want affected, then you will have to create a skin and use the skinning keys which are meant to target particular DOM elements, like ::label or ::icon-style.
partialTriggers | String[] | Yes | the IDs of the components that should trigger a partial update. This component will listen on the trigger components. If one of the trigger components receives an event that will cause it to update in some way, this component will request to be updated too. Identifiers are relative to the source component (this component), and must account for NamingContainers. If your component is already inside of a naming container, you can use a single colon to start the search from the root of the page, or multiple colons to move up through the NamingContainers - "::" will pop out of the component's naming container (or itself if the component is a naming container) and begin the search from there, ":::" will pop out of two naming containers (including itself if the component is a naming container) and begin the search from there, etc.
rendered | boolean | Yes | Default Value: true whether the component is rendered. When set to false, no output will be delivered for this component (the component will not in any way be rendered, and cannot be made visible on the client). If you want to change a component's rendered attribute from false to true using PPR, set the partialTrigger attribute of its parent component so the parent refreshes and in turn will render this component.
shortDesc | String | Yes | the short description of the component. The shortDesc text may be used in two different ways, depending on the component. For components with images, the shortDesc is often used to render an HTML alt attribute for the image. Please see the accessibility guidelines section for correct alt text usage of the shortDesc attribute. shortDesc is also commonly used to render an HTML title attribute, which is used by user agents to display tooltip help text. In this case the behavior for the tooltip is controlled by the user agent, e.g. Firefox 2 truncates long tooltips. For form components, the shortDesc is displayed in a note window. For components that support the helpTopicId attribute and are not using the shortDesc as image alt text, it is recommended that helpTopicId is used instead of shortDesc as it is more flexible and provides more accessible descriptive text than the use of the title attribute.
stretchId | String | Yes | the id of a child component that will be given all of the available space left in the toolbar if the contents of the toolbar do not use all of the space that the toolbar has available. The component that you specify must be present on the client. Therefore, if using a component that may not be present on the client (like af:spacer), you should set the child component's clientComponent attribute to 'true'.
styleClass | String | Yes | a CSS style class to use for this component. The style class can be defined in your jspx page or in a skinning CSS file, for example, or you can use one of our public style classes, like 'AFInstructionText'.
unsecure | java.util.Set | Yes | A whitespace separated list of attributes whose values ordinarily can be set only on the server, but need to be settable on the client. Currently, this is supported only for the "disabled" attribute. Note that when you are able to set a property on the client, you will be allowed to by using the the .setProperty('attribute', newValue) method, but not the .setXXXAttribute(newValue) method. For example, if you have unsecure="disabled", then on the client you can use the method .setProperty('disabled', false), while the method .setDisabled(false) will not work and will provide a javascript error that setDisabled is not a function.
visible | boolean | Yes | Default Value: true the visibility of the component. If it is "false", the component will be hidden on the client. Unlike "rendered", this does not affect the lifecycle on the server - the component may have its bindings executed, etc. - and the visibility of the component can be toggled on and off on the client, or toggled with PPR. When "rendered" is false, the component will not in any way be rendered, and cannot be made visible on the client. In most cases, use the "rendered" property instead of the "visible" property. Not supported on the following renderkits: org.apache.myfaces.trinidad.core