Class Roles

java.lang.Object
com.google.gwt.aria.client.Roles

public final class Roles extends Object

A factory providing each concrete role in the ARIA specification. Each role implements methods that a GWT application can use to modify the appropriate DOM attributes for that role.

For example, suppose our GWT app has a image button and we want to make it visible in screen readers as a button with some help text. To do this, we add a button role to the image and set the ARIA label property to the help text that the screen reader can use:

    Roles.getButtonRole().set(img.getElement());
    Roles.getButtonRole().setAriaLabelProperty(img.getElement(), "some help text");
 

Most ARIA properties have a prefix of "aria-" and only affect screen readers, but there is one exception: the "tabindex" property is the same one used for tab order in regular widgets. For example, to set tabindex to 0 for the button:

   Roles.getButtonRole().setTabindexExtraAttribute(img.getElement(), 0);
 

When the button changes state (it's enabled or disabled), we can change the ARIA enabled state to match, like this:

   Roles.getButtonRole().setAriaEnabledState(img.getElement(), isEnabled);
 

ARIA distinguishes between properties (which change rarely and could be set in static HTML) and states (which need to be updated in response to user input). This distinction can get a bit blurry when a GWT app updates the DOM dynamically. Generally you should update ARIA attributes at the same time that you change the CSS styles on a DOM node, so that a screen reader will see the same state as someone viewing the page visually.

The role interfaces form a hierarchy whose root is the Role interface, which contains generic methods that aren't specific to a role. Some abstract roles include:

  1. WidgetRole, for DOM elements that represent either standalone or composite widgets.
  2. CompositeRole, for widgets that contain other widgets.
  3. StructureRole, for DOM elements that are part of the page layout.
  4. LandmarkRole, for DOM elements defining common regions of a page.
  5. WindowRole, for DOM elements that define windows and dialogs.

See Also:
  • Constructor Details

    • Roles

      public Roles()
  • Method Details

    • getAlertdialogRole

      public static AlertdialogRole getAlertdialogRole()
    • getAlertRole

      public static AlertRole getAlertRole()
    • getApplicationRole

      public static ApplicationRole getApplicationRole()
    • getArticleRole

      public static ArticleRole getArticleRole()
    • getBannerRole

      public static BannerRole getBannerRole()
    • getButtonRole

      public static ButtonRole getButtonRole()
    • getCheckboxRole

      public static CheckboxRole getCheckboxRole()
    • getColumnheaderRole

      public static ColumnheaderRole getColumnheaderRole()
    • getComboboxRole

      public static ComboboxRole getComboboxRole()
    • getComplementaryRole

      public static ComplementaryRole getComplementaryRole()
    • getContentinfoRole

      public static ContentinfoRole getContentinfoRole()
    • getDefinitionRole

      public static DefinitionRole getDefinitionRole()
    • getDialogRole

      public static DialogRole getDialogRole()
    • getDirectoryRole

      public static DirectoryRole getDirectoryRole()
    • getDocumentRole

      public static DocumentRole getDocumentRole()
    • getFormRole

      public static FormRole getFormRole()
    • getGridcellRole

      public static GridcellRole getGridcellRole()
    • getGridRole

      public static GridRole getGridRole()
    • getGroupRole

      public static GroupRole getGroupRole()
    • getHeadingRole

      public static HeadingRole getHeadingRole()
    • getImgRole

      public static ImgRole getImgRole()
    • getLinkRole

      public static LinkRole getLinkRole()
    • getListboxRole

      public static ListboxRole getListboxRole()
    • getListitemRole

      public static ListitemRole getListitemRole()
    • getListRole

      public static ListRole getListRole()
    • getLogRole

      public static LogRole getLogRole()
    • getMainRole

      public static MainRole getMainRole()
    • getMarqueeRole

      public static MarqueeRole getMarqueeRole()
    • getMathRole

      public static MathRole getMathRole()
    • getMenubarRole

      public static MenubarRole getMenubarRole()
    • getMenuitemcheckboxRole

      public static MenuitemcheckboxRole getMenuitemcheckboxRole()
    • getMenuitemradioRole

      public static MenuitemradioRole getMenuitemradioRole()
    • getMenuitemRole

      public static MenuitemRole getMenuitemRole()
    • getMenuRole

      public static MenuRole getMenuRole()
    • getNavigationRole

      public static NavigationRole getNavigationRole()
    • getNoteRole

      public static NoteRole getNoteRole()
    • getOptionRole

      public static OptionRole getOptionRole()
    • getPresentationRole

      public static PresentationRole getPresentationRole()
    • getProgressbarRole

      public static ProgressbarRole getProgressbarRole()
    • getRadiogroupRole

      public static RadiogroupRole getRadiogroupRole()
    • getRadioRole

      public static RadioRole getRadioRole()
    • getRegionRole

      public static RegionRole getRegionRole()
    • getRowgroupRole

      public static RowgroupRole getRowgroupRole()
    • getRowheaderRole

      public static RowheaderRole getRowheaderRole()
    • getRowRole

      public static RowRole getRowRole()
    • getScrollbarRole

      public static ScrollbarRole getScrollbarRole()
    • getSearchRole

      public static SearchRole getSearchRole()
    • getSeparatorRole

      public static SeparatorRole getSeparatorRole()
    • getSliderRole

      public static SliderRole getSliderRole()
    • getSpinbuttonRole

      public static SpinbuttonRole getSpinbuttonRole()
    • getStatusRole

      public static StatusRole getStatusRole()
    • getTablistRole

      public static TablistRole getTablistRole()
    • getTabpanelRole

      public static TabpanelRole getTabpanelRole()
    • getTabRole

      public static TabRole getTabRole()
    • getTextboxRole

      public static TextboxRole getTextboxRole()
    • getTimerRole

      public static TimerRole getTimerRole()
    • getToolbarRole

      public static ToolbarRole getToolbarRole()
    • getTooltipRole

      public static TooltipRole getTooltipRole()
    • getTreegridRole

      public static TreegridRole getTreegridRole()
    • getTreeitemRole

      public static TreeitemRole getTreeitemRole()
    • getTreeRole

      public static TreeRole getTreeRole()
    • roleOf

      public static Role roleOf(Element element)
      Returns the WAI-ARIA role for the element. If no 'role' attribute is set to the element or if the set role tokens do not include a WAI-ARIA role, null is returned. Otherwise, if a WAI_ARIA role is among the role tokens in the 'role' attribute token list, a Role corresponding the WAI-ARIA role is returned.