Widgets in the APS JS SDK can be declared using either Widget Loader, or Widget Constructor, or Declarative Method as explained here.
In this document:
You can declare SDK widgets using a JavaScript array. The best way is to
use the load
method provided by the aps/load
module. This method can accept two arguments:
JSON object describing a widget or an array of such objects
Optionally, a DOMNode ID or DOMNode itself, where the required widgets will be added to
require(["aps/load", "aps/ready!"],
function(load){
load([ "aps/ProgressBar", { value: "35%" } ]);
});
For more details, refer to Widget Loader.
You can declare SDK widgets using JavaScript constructors. Preliminary, declare the SDK modules that will be used in the view and associate the names of constructors with them.
require(["aps/Button", "aps/ready!"],
function(Button){
var btn = new Button({
id: "example1",
label: "I am simple button"
}, "idDiv");
});
For more details, refer to Widget Constructors.
In old APS packages, you can meet the declaration of widgets directly in a screen’s HTML layout. For example:
require(["dojo/parser", "aps/ready!"],
function(parser){
parser.parse();
});
<div dojoType="aps/CheckBox" title="decCheckBox" data-dojo-props="value: 'helloHTML'"></div>
For more details refer to Declarative Method.
Warning
The declarative method is not recommended and wherever possible we recommend you
to use the aps/load
method.
All the declaration methods are applicable for any widget. To use a widget after it was created using the loader or declaratively, find it by its Widget ID. This may be useful, for example, in case of updating a view when a certain event occurs.