Oracle Fusion Middleware Tag Reference for Oracle ADF Faces
11g Release 2 (11.1.2.1.0)

E17491-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 commandToolbarButtons and groups of commandToolbarButtons. Toolbars are not rendered on printable pages.

Allowed Children

While a toolbar was designed to hold commandToolbarButtons, 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 include separators around the group. You should also note that the group has an effect on certain items. For example, commandToolbarButtons with type of radio that are grouped together are automatically considered part of the same radio group.

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.

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:commandToolbarButton text="Forward"
                               icon="/images/fwdarrow_gray.gif"
                               disabled="true"
                               id="ctb1"/>
      <af:commandToolbarButton icon="/images/uplevel.gif" 
                               id="ctb2"/>
    </af:group>
    <af:commandToolbarButton text="Search"
                             icon="/images/search.gif" 
                             id="ctb3"/>
    <af:commandToolbarButton text="Folders"
                             icon="/images/folders.gif" 
                             id="ctb4"/>
            
    
    <af:spacer id="stretch1" clientComponent="true"/>
            
    <af:commandToolbarButton text="Reports" 
                             id="ctb5"/>
    <af:commandToolbarButton text="Refresh:OFF" 
                             id="ctb6"/>
  </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 ParialTriggers

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

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:

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:

Screen Shot(s)


toolbar screenshot
Toolbar component with 4 commandToolbarButton components.

Code Example(s)

<af:toolbar id="tb1">
   <af:group id="g1">
      <af:commandToolbarButton text="Search" icon="/images/search.gif" id="ctb1"/>
      <af:commandToolbarButton text="Folders" icon="/images/folders.gif" id="ctb2"/>
   </af:group>
   <af:group id="g2">
      <af:commandToolbarButton text="Reports" id="ctb3"/>
      <af:commandToolbarButton text="Refresh:OFF" id="ctb4"/>
   </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 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.
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 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. The identifier must follow a subset of the syntax allowed in HTML:
  • Must not be a zero-length String.
  • First character must be an ASCII letter (A-Za-z) or an underscore ('_').
  • Subsequent characters must be an ASCII letter or digit (A-Za-z0-9), an underscore ('_'), or a dash ('-').
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 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. This text is commonly used by user agents to display tooltip help text, in which 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 it is recommended that helpTopicId is used as it is more flexible and is more accessibility-compliant.
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 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