ActionContext Class
The main point of entry for all mojits into Mojito. The Action Context is passed to every mojit action during execution, either on the client or server. This object is the API into Mojito, can can have many plugins attached the provide extra functionality.
Item Index
Methods
_dispatch
-
command -
adapter
This _dispatch function is called one time per Mojito execution. It creates a contextualized Y instance for all further internal dispatches to use. It also creates the ActionContext for the mojit.
The command has three main parts: the "instance", the "context", and the "params".
command: {
instance: ...see below...
context: ...see below...
params: ...see below...
}
The "instance" is a partial instance with details of the mojit instance.
See ServerStore.expandInstance() for details of the structure and which
fields are required.
The "context" is the request context. It is built by the "contextualizer" middleware.
The "params" is a structured set of parameters to pass to the mojit.
params: {
route: {},
url: {},
body: {},
file: {},
...
}
adapter: {
flush: function(data, meta){},
done: function(data, meta){},
error: function(err){}
}
Parameters:
-
commandMapthe "command" describing how to dispatch the mojit. See above.
-
adapterObjectthe output adapter to pass to the mojit. See above.
_simulateResponse
-
id -
details -
badcookie
Simulate a server response
Parameters:
-
idNumberthe id of the transaction.
-
detailsObjectthe details of the response.
-
badcookieBooleanOptional. If true simulate cookies turned off.
_wsRequestFormatter
()
Object
private
Format web service requests using var foo = function() format so that reset is easier.
Returns:
destroy
()
Called by the bean registry whenever this bean is reinitialized
disable
-
queue
Disables all Ajax requests for the application.
Parameters:
-
queueBoolean(Optional) When set to true, queues all requests while disabled.
dispatch
-
command -
adapter
This dispatch function is called one time per Mojito execution. It creates a contextualized Y instance for all further internal dispatches to use. It also creates the ActionContext for the mojit.
The command has three main parts: the "instance", the "context", and the "params".
command: {
instance: ...see below...
context: ...see below...
params: ...see below...
}
The "instance" is a partial instance with details of the mojit instance.
See ServerStore.expandInstance() for details of the structure and which
fields are required.
The "context" is the request context. It is built by the "contextualizer" middleware.
The "params" is a structured set of parameters to pass to the mojit.
params: {
route: {},
url: {},
body: {},
file: {},
...
}
adapter: {
flush: function(data, meta){},
done: function(data, meta){},
error: function(err){}
}
Parameters:
-
commandMapthe "command" describing how to dispatch the mojit. See above.
-
adapterObjectthe output adapter to pass to the mojit. See above.
done
-
data -
meta
Returns data and closes the request.
Parameters:
-
dataObject | StringThe data you want return by the request.
-
metaObjectAny meta-data required to service the request.
enable
()
Enables sending of requests.
error
-
err
Programatically report an error to Mojito, which will handle it gracefully.
Parameters:
-
errErrorA normal JavaScript Error object is expected, but you may add a "code" property to the error if you want the framework to report a certain HTTP status code for the error. For example, if the status code is 404, Mojito will generate a 404 page.
execute
-
url -
data -
method
Executes an io request.
Parameters:
-
urlStringUrl to access.
-
dataObjectThe data to send.
-
methodStringGET or POST.
flush
-
data -
meta
Returns data in the request and allows you to carry on execution.
Parameters:
-
dataObject | StringThe data you want return by the request.
-
metaObjectAny meta-data required to service the request.
setRequestFormatter
-
requestType -
formatter
Sets the request formatter function for a given request type.
Parameters:
-
requestTypeStringThe type of request that the formatter should handle.
-
formatterFunctionThe function to call to format the request.
setResponseFormatter
-
formatter
Sets the response formatter function for all responses.
Parameters:
-
formatterFunctionThe function to call to format the response object.
