Thursday, January 22, 2009

Javascript root objects available for webscript

In this post I'm quoting the wiki content for the sake of ease to find it later.

One link that might be of interest : Javascript API cookbook

The following JavaScript root objects are available to all Web Scripts, regardless of their hosting environment.

args
an associative array of all URI parameters. See example.
argsM
an associative array of all URI parameters (where each key is an argument name and each value is an array containing all respective argument values, even if only one is supplied). See example.
headers
an associative array of all request headers.
headersM
an associative array of all request headers (where each key is an header name and each value is an array containing all respective header values, even if only one is supplied). See example.
url
provides access to the URI (or parts of the URI) that triggered the web script.
model
An empty associative array which may be populated by the JavaScript. Values placed into this array are available as root objects in Web Script response templates.
status
provides ability to control response status codes.
cache
provides ability to control caching of response.
config
provides access to the Web Script configuration.
msg
provides access to Web Script localized messages.
format
provides information on the response format to be rendered.
guest
A boolean indicating whether the web script is executing as "Guest".
webscript
An associative array of meta-data properties describing the Web Script.
server
An associative array of meta-data properties describing the server hosting the Web Script.
jsonUtils
A host object for parsing and generating JSON objects.
atom
A host object for parsing and generating Atom (Publishing) documents.
logger
A host object providing access to console logging facilities for debugging of scripts. See the Logging API.

Web Scripts hosted within the Alfresco Repository tier also have access to the following root objects which provide direct access to Repository services and content.

roothome
the repository root node (only available if authenticated)
companyhome
the company home folder (only available if authenticated)
person
the person node of the currently authenticated user (only available if authenticated)
userhome
the user home folder (only available if authenticated)
search
A host object providing access to Lucene and Saved Search results. See the Search API.
people
A host object providing access to Alfresco people and groups. See the People API.
actions
A host object providing invocation of registered Alfresco Actions. See the Actions API.
session
Session related information such as the current authentication ticket. See the Session API.
classification
Access to the root elements of the classification API. See the Classification API.
utils
Access to a library of useful helper functions not provided as part of generic JavaScript. See the Utility Functions.
avm
Access to WCM objects such as AVM paths and searching within AVM stores and web projects. See the AVM API.
crossRepoCopy
Cross repository copy support. See the Cross Repository Copy.
workflow
Start workflows and access, control in-flight workflows. See the JavaScript API#Workflow API.

Web Scripts hosted within the presentation tier (i.e. within Alfresco SURF) have their own extras as described in the Surf Platform - Freemarker Template and JavaScript API.

No comments: