Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Because commands are encapsulated into their own objects with no reference for the user interface or their visual representation, you need a builder pattern to generate widgets from commands in a generic manner.
A command consumer (or other objects that are responsible for displaying commands in the user interface) should instantiate a builder based on what you want to display. For example, if a button is the type of widget you want then use a button builder.
The builders have two public methods:
The following example shows the button builder in use:
require([
"dijit/Toolbar",
"epi/shell/command/builder/ButtonBuilder",
"epi/shell/command/ToggleCommand"
], function (Toolbar, ButtonBuilder, ToggleCommand) {
var toolbar = new Toolbar(),
builder = new ButtonBuilder(),
model = { enabled: true },
command = new ToggleCommand({
model: model,
property: "enabled"
});
builder.create(command, toolbar);
});
Last updated: Sep 21, 2015