aps/Output

A simple widget that displays templated output (or simple HTML/Text), parts of which may be data-bound.

Use a template only when using the ``load`` method or declarative syntax. You cannot use a template with programmatic declaration.

Compatibility

All user panels - CP and UX1

Overview

With the Output widget you can display on the screen text, HTML or data from a model while keeping the entire functionality intrinsic for widgets. Regardless of the fact that the widget is able outputting arbitrary HTML, you should output a maximally simple code. To define complex constructs, it is better to use the Container widget or declarative syntax.

Find the nested rules for this widget in the recommended Widget Hierarchy.

Widget’s content may be specified through the value property or through the content property. When you configure a certain output, the value property should be used. If you need to define a template that will contain additional properties, then you should use the content property.

Note

HTML code is not escaped in the content field, but it is escaped in the other properties. Refer to Probable Threats related with it.

You can mark up the text in the widget by assigning one of the following values to the alertType property:

  • success

  • info

  • warning

  • danger

Examples

In a case you need to print out an HTML code in a container widget, use the Output widget inside the widget. For example, in a FieldSet widget:

RUN DEMO

require(["aps/load", "aps/ready!"],
  function(load){
    "use strict";

    load(["aps/PageContainer", [
        ["aps/Panel", [
            ["aps/FieldSet", { showLabels: false },
                [[ "aps/Output", {
                    label: "OS",
                    value: "CentOS 6 (x86_64)"
                }],
                [ "aps/Output", {
                    label: "Source Image",
                    content: "<a href='https://www.centos.org/images/logo_small.png'>View CentOS icon</a>"
                }]]
            ]
        ]]
    ]]);
});

You can link Output with a Model component using the at module (for details see Model ). To insert data into the text being output, use the standard template syntax. To refer to a widget’s property, enter the property name using the ${property_name} syntax.

RUN DEMO

require(["dojox/mvc/getStateful", "aps/load", "dojox/mvc/at", "aps/ready!"],
  function(getStateful, load, at) {
    "use strict";

    var model = getStateful({ "num": 0 });

    load(["aps/PageContainer", [
        ["aps/Panel", [
            [ "aps/Output", {
                content: "This is ${num}",
                num: at(model, 'num')
    }]]]]]);

    setInterval(function(){ model.set("num", model.num+1); }, 1000);
});

Public Properties

PROPERTY

TYPE

DEFAULT

DESCRIPTION

alertType

string

default

Type of visual format.

content

string

${value}

Pattern of the widget contents.

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.

isBusy

boolean

false

If the widget is busy then this property is true.

label

string

“”

Text that is shown as a label if the widget is placed inside a aps/FieldSet.

value

string

“”

Widget contents.

visible

boolean

true

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

alertType string

Type of visual format. Only for CCP v2. Possible values: “info”, “warning”, “danger”, “default”. Default value: “default”.

content string

Pattern of the widget contents. Default value: “${value}”.

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.

isBusy boolean

If the widget is busy then this property is true.

Default value: false.

label string

Text that is shown as a label if the widget is placed inside a aps/FieldSet.

Default value: “”.

value string

Widget contents. Does not support patterns. Default value: “”.

visible boolean

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

Default value: true.

Public Methods

METHOD

RETURN

DESCRIPTION

cancel ()

object

Sets the isBusy property to false

destroy ()

undefined

Destroys this widget

get ()

any

Get a property of the Stateful instance

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

set (name)

aps/output
function

Override and refresh output on value change

startup ()

undefined

Gets started after the DOM fragment is added to the document

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

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

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

set

Override and refresh output on value change.

Return: aps/output function

ARGUMENT

TYPE

DESCRIPTION

name

undefined

The property to set.

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

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.