Class Roles
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:
WidgetRole, for DOM elements that represent either standalone or composite widgets.CompositeRole, for widgets that contain other widgets.StructureRole, for DOM elements that are part of the page layout.LandmarkRole, for DOM elements defining common regions of a page.WindowRole, for DOM elements that define windows and dialogs.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AlertdialogRolestatic AlertRolestatic ApplicationRolestatic ArticleRolestatic BannerRolestatic ButtonRolestatic CheckboxRolestatic ColumnheaderRolestatic ComboboxRolestatic ComplementaryRolestatic ContentinfoRolestatic DefinitionRolestatic DialogRolestatic DirectoryRolestatic DocumentRolestatic FormRolestatic GridcellRolestatic GridRolestatic GroupRolestatic HeadingRolestatic ImgRolestatic LinkRolestatic ListboxRolestatic ListitemRolestatic ListRolestatic LogRolestatic MainRolestatic MarqueeRolestatic MathRolestatic MenubarRolestatic MenuitemcheckboxRolestatic MenuitemradioRolestatic MenuitemRolestatic MenuRolestatic NavigationRolestatic NoteRolestatic OptionRolestatic PresentationRolestatic ProgressbarRolestatic RadiogroupRolestatic RadioRolestatic RegionRolestatic RowgroupRolestatic RowheaderRolestatic RowRolestatic ScrollbarRolestatic SearchRolestatic SeparatorRolestatic SliderRolestatic SpinbuttonRolestatic StatusRolestatic TablistRolestatic TabpanelRolestatic TabRolestatic TextboxRolestatic TimerRolestatic ToolbarRolestatic TooltipRolestatic TreegridRolestatic TreeitemRolestatic TreeRolestatic RoleReturns the WAI-ARIA role for theelement.
-
Constructor Details
-
Roles
public Roles()
-
-
Method Details
-
getAlertdialogRole
-
getAlertRole
-
getApplicationRole
-
getArticleRole
-
getBannerRole
-
getButtonRole
-
getCheckboxRole
-
getColumnheaderRole
-
getComboboxRole
-
getComplementaryRole
-
getContentinfoRole
-
getDefinitionRole
-
getDialogRole
-
getDirectoryRole
-
getDocumentRole
-
getFormRole
-
getGridcellRole
-
getGridRole
-
getGroupRole
-
getHeadingRole
-
getImgRole
-
getLinkRole
-
getListboxRole
-
getListitemRole
-
getListRole
-
getLogRole
-
getMainRole
-
getMarqueeRole
-
getMathRole
-
getMenubarRole
-
getMenuitemcheckboxRole
-
getMenuitemradioRole
-
getMenuitemRole
-
getMenuRole
-
getNoteRole
-
getOptionRole
-
getPresentationRole
-
getProgressbarRole
-
getRadiogroupRole
-
getRadioRole
-
getRegionRole
-
getRowgroupRole
-
getRowheaderRole
-
getRowRole
-
getScrollbarRole
-
getSearchRole
-
getSeparatorRole
-
getSliderRole
-
getSpinbuttonRole
-
getStatusRole
-
getTablistRole
-
getTabpanelRole
-
getTabRole
-
getTextboxRole
-
getTimerRole
-
getToolbarRole
-
getTooltipRole
-
getTreegridRole
-
getTreeitemRole
-
getTreeRole
-
roleOf
Returns the WAI-ARIA role for theelement. If no 'role' attribute is set to theelementor 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, aRolecorresponding the WAI-ARIA role is returned.
-