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
-
Method Summary
Modifier and TypeMethodDescriptionstatic AlertdialogRole
static AlertRole
static ApplicationRole
static ArticleRole
static BannerRole
static ButtonRole
static CheckboxRole
static ColumnheaderRole
static ComboboxRole
static ComplementaryRole
static ContentinfoRole
static DefinitionRole
static DialogRole
static DirectoryRole
static DocumentRole
static FormRole
static GridcellRole
static GridRole
static GroupRole
static HeadingRole
static ImgRole
static LinkRole
static ListboxRole
static ListitemRole
static ListRole
static LogRole
static MainRole
static MarqueeRole
static MathRole
static MenubarRole
static MenuitemcheckboxRole
static MenuitemradioRole
static MenuitemRole
static MenuRole
static NavigationRole
static NoteRole
static OptionRole
static PresentationRole
static ProgressbarRole
static RadiogroupRole
static RadioRole
static RegionRole
static RowgroupRole
static RowheaderRole
static RowRole
static ScrollbarRole
static SearchRole
static SeparatorRole
static SliderRole
static SpinbuttonRole
static StatusRole
static TablistRole
static TabpanelRole
static TabRole
static TextboxRole
static TimerRole
static ToolbarRole
static TooltipRole
static TreegridRole
static TreeitemRole
static TreeRole
static Role
Returns 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 theelement
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, aRole
corresponding the WAI-ARIA role is returned.
-