Command

An abstract class used in implementing Mojo Commands.  A Command is an object that encapsulates functionality for processing data and/or business logic.

Example

dojo.provide("sample.command.LoadHtmlCommand");
dojo.require("mojo.command.Command");
dojo.require("sample.service.Locator");

dojo.declare("sample.command.LoadHtmlCommand", mojo.command.Command,
function() {
},{
execute: function(requestObj) {
// invoke a service call to get some Html
var locator = sample.service.Locator.getInstance();
var service = locator.getService("getHtml")
service.invoke(this.getRequest().getParams(), this);
},
onResponse: function(data) {
// handle success response...
},
onError: function(error) {
// handle error response...
}
});
Summary
An abstract class used in implementing Mojo Commands.
Returns the mojo.controller.Request object passed into the Command.
Abstract function that must be implemented in a concrete Command class.
Abstract function that must be implemented in a concrete Command class.
Abstract function that must be implemented in a concrete Command class.

Functions

getRequest

getRequest: function()

Returns the mojo.controller.Request object passed into the Command.

Returns

{object} Mojo Request Object

Example

//See above example implementation.

execute

execute: function(requestObj)

Abstract function that must be implemented in a concrete Command class.  The Controller will automatically fire the execute() method when triggering a Command.

Parameters

requestObj{object}

Example

//See above example implementation.

onResponse

onResponse: function(data)

Abstract function that must be implemented in a concrete Command class.  Used to handle the data from a successful response.

Parameters

data{object}

Exmaple

// see above for sample implementation usage.

onError

onError: function(error)

Abstract function that must be implemented in a concrete Command class.  Used to handle errors from an error response.

Parameters

error{object}

Example

//See above example implementation.
getRequest: function()
Returns the mojo.controller.Request object passed into the Command.
execute: function(requestObj)
Abstract function that must be implemented in a concrete Command class.
onResponse: function(data)
Abstract function that must be implemented in a concrete Command class.
onError: function(error)
Abstract function that must be implemented in a concrete Command class.