Request

Class representation of a Controller Request instance.  Encapsulates request-specific parameters, and context-specific information, into an object; used in Mojo Command, Behavior, and Rule objects.

Summary
Class representation of a Controller Request instance.
Creates an instance of the mojo.controller.Request class.
Returns the object containing the set of parameter properties and values to be used by a Command.
Returns the caller object that triggered the request.
Returns the DOM context of the Controller which fired the request.
Returns the DOM event object triggered, if applicable.
Returns the name of the Command that the request is being passed in to.
Returns the Controller which fired the request.
Returns the name of the Controller which fired the request.
Returns the invocation object, which wraps an intercepted Command object.

Functions

constructor

constructor: function(paramsObj,
callerObj,
eventObj,
commandName,
controllerObj,
invocation)

Creates an instance of the mojo.controller.Request class.

Parameters

paramsObj{object}
callerObj{object}
eventObj{event}
commandName{string}
controllerObj{mojo.controller.Controller}
invocation{object}

getParams

getParams: function()

Returns the object containing the set of parameter properties and values to be used by a Command.

Returns

{object} paramsObj

Example

// use requestObj passed into a Command
var targetParam = requestObj.getParams().target;

getCaller

getCaller: function()

Returns the caller object that triggered the request.

Returns

{object} callerObj

Example

// use requestObj passed into a Command
// check if object triggering request is a mojo.MessagingTopic
if (requestObj.getCaller() instanceof mojo.MessagingTopic) {
var msg = requestObj.getCaller().getMessage(); // get message
}

getContextElement

getContextElement: function()

Returns the DOM context of the Controller which fired the request.

Returns

{DOMElement} contextObj

Example

// use requestObj passed into a Command
// only do css queries within the context of the Controller
var selectedList = mojo.query(".selected", requestObj.getContextElement());

getEvent

getEvent: function()

Returns the DOM event object triggered, if applicable.

Returns

{event} eventObj

Example

// use requestObj passed into a Command
var x = requestObj.getEvent().offsetX;
var y = requestObj.getEvent().offsetY;

getCommandName

getCommandName: function()

Returns the name of the Command that the request is being passed in to.

Returns

{string} Command Name

getController

getController: function()

Returns the Controller which fired the request.

Returns

{mojo.controller.Controller} Controller

getControllerName

getControllerName: function()

Returns the name of the Controller which fired the request.

Returns

{string} Controller Name

getInvocation

getInvocation: function()

Returns the invocation object, which wraps an intercepted Command object.  Used with Controller Intercepts only.

Returns

{object} Invocation

Example

// use requestObj passed into a Command
if (requestObj.getInvocation()) {
// execute the intercepted Command
requestObj.getInvocation().proceed();
}
constructor: function(paramsObj,
callerObj,
eventObj,
commandName,
controllerObj,
invocation)
Creates an instance of the mojo.controller.Request class.
getParams: function()
Returns the object containing the set of parameter properties and values to be used by a Command.
getCaller: function()
Returns the caller object that triggered the request.
getContextElement: function()
Returns the DOM context of the Controller which fired the request.
getEvent: function()
Returns the DOM event object triggered, if applicable.
getCommandName: function()
Returns the name of the Command that the request is being passed in to.
getController: function()
Returns the Controller which fired the request.
getControllerName: function()
Returns the name of the Controller which fired the request.
getInvocation: function()
Returns the invocation object, which wraps an intercepted Command object.