public final class Roles
extends java.lang.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:
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.Constructor and Description |
---|
Roles() |
public static AlertdialogRole getAlertdialogRole()
public static AlertRole getAlertRole()
public static ApplicationRole getApplicationRole()
public static ArticleRole getArticleRole()
public static BannerRole getBannerRole()
public static ButtonRole getButtonRole()
public static CheckboxRole getCheckboxRole()
public static ColumnheaderRole getColumnheaderRole()
public static ComboboxRole getComboboxRole()
public static ComplementaryRole getComplementaryRole()
public static ContentinfoRole getContentinfoRole()
public static DefinitionRole getDefinitionRole()
public static DialogRole getDialogRole()
public static DirectoryRole getDirectoryRole()
public static DocumentRole getDocumentRole()
public static FormRole getFormRole()
public static GridcellRole getGridcellRole()
public static GridRole getGridRole()
public static GroupRole getGroupRole()
public static HeadingRole getHeadingRole()
public static ImgRole getImgRole()
public static LinkRole getLinkRole()
public static ListboxRole getListboxRole()
public static ListitemRole getListitemRole()
public static ListRole getListRole()
public static LogRole getLogRole()
public static MainRole getMainRole()
public static MarqueeRole getMarqueeRole()
public static MathRole getMathRole()
public static MenubarRole getMenubarRole()
public static MenuitemcheckboxRole getMenuitemcheckboxRole()
public static MenuitemradioRole getMenuitemradioRole()
public static MenuitemRole getMenuitemRole()
public static MenuRole getMenuRole()
public static NavigationRole getNavigationRole()
public static NoteRole getNoteRole()
public static OptionRole getOptionRole()
public static PresentationRole getPresentationRole()
public static ProgressbarRole getProgressbarRole()
public static RadiogroupRole getRadiogroupRole()
public static RadioRole getRadioRole()
public static RegionRole getRegionRole()
public static RowgroupRole getRowgroupRole()
public static RowheaderRole getRowheaderRole()
public static RowRole getRowRole()
public static ScrollbarRole getScrollbarRole()
public static SearchRole getSearchRole()
public static SeparatorRole getSeparatorRole()
public static SliderRole getSliderRole()
public static SpinbuttonRole getSpinbuttonRole()
public static StatusRole getStatusRole()
public static TablistRole getTablistRole()
public static TabpanelRole getTabpanelRole()
public static TabRole getTabRole()
public static TextboxRole getTextboxRole()
public static TimerRole getTimerRole()
public static ToolbarRole getToolbarRole()
public static TooltipRole getTooltipRole()
public static TreegridRole getTreegridRole()
public static TreeitemRole getTreeitemRole()
public static TreeRole getTreeRole()
public static Role roleOf(Element element)
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.