Table Of Contents

Application Packaging Standard

Last updated 18-Mar-2019

aps/MessageList

Specifies a container for messages.

Compatibility

All user panels - CP and UX1

Overview

An aps/MessageList object is a container that allows creating and deleting messages and other widgets inside it. When a user navigates from view to view, the control panel cleans up the message list.

You should not create instances of this container, because the root aps/PageContainer already has the aps/MessageList container as a child. The messageList property of the parent refers to the message list. Use this property as demonstrated in the Example.

By default, the message list ensures uniqueness of its child messages. It means, if a program code adds a message whose contents duplicates an existing message, the latest message will replace the existing one. The uniqueMessages property defines this behavior. The following example demonstrates how to change it.

var msglist = page.get("messageList");
msglist.set("uniqueMessages", false);

In this example, page is the aps/PageContainer container.

Example

The following code demonstrates how to embed and remove messages in the aps/MessageList container.

RUN DEMO

require([
	"aps/PageContainer",
	"aps/Message",
	"aps/Button",
	"dojo/_base/array",
	"aps/ready!"
], function(PageContainer, Message, Button, array) {
	"use strict";

	var page = new PageContainer({}, "main");

	var msglist = page.get("messageList");

	msglist.addChild(new Message({
		description: "Warning message",
		type: "warning"
	}));

	msglist.addChild(new Message({
		description: "Error message - you cannot close it!",
		type: "error",
		closeable: false
	}));

	msglist.addChild(new Message({
		description: "Informational message",
		type: "info"
	}));

	msglist.addChild(new Message({
		description: "Process in progress - try to make it visible",
		type: "progress",
		visible: false
	}));

	msglist.addChild(new Message({
		description: "Update message",
		type: "update"
	}));

	msglist.addChild(new Message({
		description: "Limit is reached",
		type: "limits"
	}));

	msglist.addChild(new Button({
		title: "Remove Error Messages",
		onClick: function() {
			var list = page.get("messageList");
			array.forEach(list.getChildren(), (function(item) {
				if (item.type === "error") {
					list.removeChild(item);
				}
			}));
		}
	}));

	page.startup();
});

Public Properties

PROPERTY TYPE DEFAULT DESCRIPTION
disabled boolean false Specifies if the widget will respond to user input.
gridSize string undefined This specifies the widget width that is relevant only for widgets inside Container, FieldSet, or Tiles.
uniqueMessages boolean true If true, then the MessageList widget requires all child Message widgets to have unique description property.
visible boolean false If this property value is set to true, then the widget is visible.

disabled boolean

Specifies if the widget will respond to user input.

Default value: false.

gridSize string

This specifies the widget width that is relevant only for widgets inside Container, FieldSet, or Tiles. In other cases it will be ignored.

gridSize string contains few options with number values (from 1 to 12) separated by spaces, which specify the grid size of the widget in different layouts:

- md - desktop

- xs - phone

For example, gridSize: “md-4 xs-2”.

All values below 1, e.g. “md-0”, will be replaced with the empty string (“”), values above 12, e.g. “md-14”, will be reduced to 12 (“md-12”).

Default value: undefined.

uniqueMessages boolean

If true, then the MessageList widget requires all child Message widgets to have unique description property. When adding a new message with a certain description, all existing messages with the same description will be removed and replaced by the new one.

Default value: true.

visible boolean

If this property value is set to true, then the widget is visible.

Default value: false.

Public Methods

METHOD RETURN DESCRIPTION
add (message, type)
undefined
Adds the specified message of the required type (“error” type by default)
addChild (child)
undefined
Makes the given widget a child of this widget
cancel ()
object
Sets the isBusy property to false
destroy ()
undefined
Destroys this widget
focus ()
aps/_containerbase
function
Focusing the focusable child
get ()
any
Get a property of the Stateful instance
getChildren ()
array
Returns all direct children of this widget, i
getParents ()
array
Discover and return all parents of the widget
placeAt ()
dijit/_widgetbase
function
Place this widget somewhere in the DOM based on standard dojo/dom-construct::place() conventions
removeAll ()
undefined
Remove all children in the widget
removeChild ()
undefined
Removes the passed widget instance from this widget and destroys it
reset ()
undefined
Resets the widget
set ()
object
function
Set a property of the Stateful instance
startup ()
undefined
Gets started after the DOM fragment is added to the document
validate ()
boolean
Called by oninit, onblur, and onkeypress

add

Adds the specified message of the required type (“error” type by default).

Return: undefined

ARGUMENT TYPE DESCRIPTION
message
String
object

Message description string or message params object:

{
    id:             "messageId",
    description:    "Other text",
    type:           "error"
}
type
String
Type of message.

addChild

Makes the given widget a child of this widget. Inserts specified child widget’s dom node as a child of this widget’s container node, and possibly does other processing (such as layout).

Return: undefined

ARGUMENT TYPE DESCRIPTION
child
Widget
Child widget

cancel

Sets the isBusy property to false.

Return: object

destroy

Destroys this widget. Will also destroy any resources (including widgets) registered via this.own(). This method will also destroy internal widgets such as those created from a template.

Return: undefined

focus

Focusing the focusable child

Return: aps/_containerbase function

get

Get a property of the Stateful instance. Get a named property of the Stateful object. The property may potentially be retrieved via a getter method in subclasses.

In the base class, this just retrieves the object’s property.

Return: any

getChildren

Returns all direct children of this widget, i.e. all widgets underneath this.containerNode whose parent is this widget. Note that it returns not all descendetns, but only the direct children. Analogous to Node.childNodes, except containing widgets rather than DOMNodes.

The result intentionally excludes internally created widgets (a.k.a. supporting widgets) outside of this.containerNode.

Note the returned array is a simple array. The application code should not assume existence of methods like forEach().

Return: array

getParents

Discover and return all parents of the widget.

Return: array

placeAt

Place this widget somewhere in the DOM based on standard dojo/dom-construct::place() conventions. A convenience function providing a simple shorthand mechanism to put an existing (or newly created) widget somewhere in the DOM, and allow chaining.

Return: dijit/_widgetbase function

removeAll

Remove all children in the widget.

Return: undefined

removeChild

Removes the passed widget instance from this widget and destroys it. You can also pass in an integer indicating the index within the container to remove (ie, removeChild(5) removes the sixth widget).

Return: undefined

reset

Resets the widget.

Return: undefined

set

Set a property of the Stateful instance. Sets named properties of the stateful object and notifies the watchers of the property. A programmatic setter may be defined in subclasses.

Return: object function

startup

Gets started after the DOM fragment is added to the document Called after the widget and its children have been created and added to the page, and all related widgets have finished their create() cycle, up through postCreate().

Note that startup() may be called while the widget is still hidden, for example if the widget is inside a hidden dijit/Dialog or an unselected tab of a dijit/layout/TabContainer. For widgets that need to do layout, it’s best to put that layout code inside resize(), and then extend dijit/layout/_LayoutWidget so that resize() is called when the widget is visible.

Return: undefined

validate

Called by oninit, onblur, and onkeypress. Show missing or invalid messages if appropriate, and highlight textbox field.

Return: boolean

Public Events

EVENT RETURN DESCRIPTION
onClick ()
undefined
The method is called when a user clicks on the widget

onClick

The method is called when a user clicks on the widget.