Skip to content

WAjaxPollingRegion

Mark Reeves edited this page Jan 3, 2018 · 9 revisions

WAjaxPollingRegion is a utility class which provides a WPanel containing a WAjaxControl. The WAjaxControl targets its containing panel and has a delay set as part of constructing the WAjaxPollingRegion.

The purpose of this is to provide a quick-and-*dirty- implementation of a container component which can continually poll the application every n milliseconds until it is disabled. This allows, for example:

Warning

This component is a legacy of a poor design decision and is almost always unfit for purpose. It may also result in uncontrollable accessibility problems for some users. It is *strongly recommended- this portmanteau component is never used in a real application.

Accessibility

Any polling or continually updating UI artefact must meet WCAG guidelines. Conformance Requirement 5: Non-Interference is the general principle which *must always- be observed when planning, designing or implementing polling regions. In particular special note should be made of guidelines 2.2 and 2.3.

With respect to 2.3.1, for example, the poll time should not be less than 334ms if the container's content between reloads is such that it exceeds the general flash or red flash thresholds.

If the polling region is used to continually update live information (rather than waiting for information as per the previous example) then the region's content should contain a mechanism to manually stop and restart polling so as to not contravene the guidelines in WCAG Guideline 2.2.

Example

To set up a container which polls for new content every 15 seconds one could use something like:

/**
 - Polling interval in milliseconds.
 */
private static final int POLL_INTERVAL = 15000;

/**
 - The polling region.
 */
private final WAjaxPollingRegion poller = new WAjaxPollingRegion(POLL_INTERVAL);

// ...
// add content to the polling region as appropriate

Problems with WAjaxPollingRegion

This component exists as a quick-and-dirty helper and has a number of issues which may cause problems.

  • The component is an extension of WPanel and therefore may accept any of the properties and layouts of WPanel. The first component in the panel is always a WAjaxControl which is a component which does not output a UI artefact. This means that under some conditions the UI may render in an unexpected manner.

  • If the WPanel has no content between polls (for example if the polling is undertaken to access a slow service) then the component may appear and cause rendering issues of the WPanel.Type is set to any decorated type (such as Type.BOX or Type.FEATURE). Therefore if the final content is required in a decorated WPanel Type then the type should be set initially to Type.PLAIN then changed to the required type during preparePaintComponent when the final content is available.

  • If accessing the contents of the WPanel using getChildAt or by iterating through the children one has to remember that child[0] is a WAjaxControl and not the first component added to the WAjaxPollingRegion in your code.

  • WAjaxPollingRegion is always a WPanel but this may not be the appropriate container for the job at hand or may not be allowed in the context where the content is being applied (see WComponent content models for more details).

For these reasons it may be more appropriate and better practice to construct custom pollers for each use-case than to rely on WAjaxPollingRegion.

Related components

Further information

Clone this wiki locally