Jaxer.Response : Object
Return to: Jaxer Framework index

Current response and its associated information.

Platform Support

Jaxer Server Framework Jaxer Client Framework
1.0 no

Constructors

Constructor Action Jaxer Server Framework Jaxer Client Framework
Jaxer.Response Constructor(Object evt) : Jaxer.Response
An instance of this object has the lifecycle of the current response and contains information about it.
Show Details 1.0 no

Jaxer.Response(Object evt) : Jaxer.Response

An instance of this object has the lifecycle of the current response and contains information about it.

Parameters
Object evt The Jaxer Core event whose data is used to initialize this Response object instance and to output to the client

Returns
Jaxer.Response Returns an instance of Response.

Properties

Property Action Jaxer Server Framework Jaxer Client Framework
headers : Object
A collection of the HTTP response headers that will be returned to the browser, as properties on this simple JavaScript object. If multiple headers have the same name, their values are given as an array. NOTE: some headers are set by the web server after Jaxer is done, and they will not appear here.
No Details 1.0 no

Functions

Method Action Jaxer Server Framework Jaxer Client Framework
earlyExit() : void
This will be true when the document processing has been exited before reaching the end of the document, via the exit() method or another method such as redirect() which uses exit() internally. When that happens, some post-processing steps such as callback proxying will be omitted.

(Advanced)
No Details 1.0 no
getContents() : String
Gets the contents (body) of the response. For regular page requests, this will return null unless setContents has been called, in which case it will return the value set by the last call to setContents. For callbacks, this should only be called at the very end of callback processing, when the contents have been explicitly set by the Jaxer framework using the setContents method.

(Advanced)
Show Details 1.0 no

Returns
String The explicitly-set contents at this time, or null if no explicit contents have been set (so the DOM will be serialized if this is a regular page request).

getDomTouched() : Boolean
Has the DOM possibly been modified in any way?

(Advanced)
Show Details 1.0 no

Returns
Boolean true if it has (or might have), false if it could not have been

getSideEffect() : Boolean
Has there been any possible side effect (e.g. database accessed, etc.)?

(Advanced)
Show Details 1.0 no

Returns
Boolean true if there has been (or might have been), false if there could not have been

noteDomTouched() : void
Remembers that the DOM has been altered in some way, which ensures that the final response will be the Jaxer-produced one rather than the original document Jaxer received.

(Advanced)
No Details 1.0 no
noteSideEffect() : void
Remembers that processing this page has had some side effect, which ensures that the final response will be treated as having been processed by Jaxer, whether or not its contents have been modified.

(Advanced)
No Details 1.0 no
useOriginalContents() : void
Once this is called, the contents of the response will be the same as the contents that Jaxer received in this request, i.e. all DOM changes will be discarded. This is ONLY effective for regular requests, not callbacks.

(Advanced)
No Details 1.0 no
addHeader(String name, String value) : void
Adds an HTTP header to the response. If an existing header with this name exists, this value will be appended -- if you don't want that, just set Jaxer.response.headers [ name ] = value
Show Details 1.0 no

Parameters
String name The name of the HTTP header
String value The value to use

exit([Number statusCode,] [String contents,] [String reasonPhrase]) : void
Stops processing the current request's HTML page and JavaScript, and returns this response to the browser via the web server.
Show Details 1.0 no

Parameters
Number statusCode (optional)The HTTP status code to return to the browser: by default it is 200.
String contents (optional)The contents to use for the body of the response. If this is null or undefined, and setContents has not been called on this response, the current DOM will be serialized and returned as the response contents. If this is an XMLDocument or an E4X XML object, its string representation will be used, and a Content-Type header of "application/xml" will be returned (unless a Content-Type header was already specified in this response)
String reasonPhrase (optional)The text description (e.g. "OK") of the status code. For all the standard status codes this is optional, as the standard description for the status code will be used by default.

See Also

Jaxer.Response.prototype.setContents|Jaxer.Response.prototype.addHeader|Jaxer.Response.prototype.redirect|Jaxer.Response.prototype.statusCodeToReasonPhrase

exposeJaxer() : void
If Jaxer.Config.EXPOSE_JAXER, this sets an "X-Powered-By" header on the response indicating that Jaxer processing has occurred and noting the build number.
No Details 1.0 no
getError() : void
Gets the error, if any, of which the framework has been notified during the handling of this request and generation of this response.
No Details 1.0 no
Gets the parameters of the alternate client framework that will be injected into this response, if the default client framework has been overridden using setClientFramework().
Show Details 1.0 no

Returns
Object A JavaScript object with properties isSrc (Boolean indicating whether the value is the src or the contents of the script block to be injected) and value (the src or the contents).

hasError() : Boolean
Has the framework been notified of an error during the handling of this request and generation of this response?
Show Details 1.0 no

Returns
Boolean True if an error was submitted.

Checks whether the client framework has been overridden for this response, i.e. whether setClientFramework has been called.
Show Details 1.0 no

Returns
Boolean true if the client framework is overridden, false otherwise

notifyError(Object newError, [Boolean avoidLogging]) : void
Notifies the framework that an error has occurred during the handling of this request and generation of this response. How this is handled is then determined by the Jaxer.Config settings.
Show Details 1.0 no

Parameters
Object newError The error describing what happened. If the framework has already been notified of an error during the current request, this newError is not used.
Boolean avoidLogging (optional)If this evaluates to true, an error message will not be logged during this call. Note that if an error message has been logged already in this request, another message will not be logged in any case.

notifyErrorShown() : void
Notifies the framework that an error has already been reported in the output page so it need not be reported in the output page again.
No Details 1.0 no
redirect(String url, [Number statusCode,] [String reasonPhrase]) : void
Stops processing the current request's HTML page and JavaScript, and returns a redirect-type HTTP response to the browser. No contents (response body) are returned to the browser, and the DOM is not serialized.
Show Details 1.0 no

Parameters
String url The URL to which the browser should redirect the request. This is mandatory unless the Location header has already been set for this response.
Number statusCode (optional)The HTTP status code to return to the browser: by default it is 307 (temporary redirect).
String reasonPhrase (optional)The text description of the status code. For all the standard status codes this is optional, as the standard description for the status code will be used by default.

See Also

Jaxer.Response.prototype.setContents|Jaxer.Response.prototype.addHeader|Jaxer.Response.prototype.exit|Jaxer.Response.prototype.statusCodeToReasonPhrase

removeHeader(String name, String value) : void
Removes an HTTP header with a specific value from the response. If there is no such name-value pair, it does nothing. If an existing header with this name exists and has multiple values, this value will be removed -- if you don't want that, just delete Jaxer.response.headers [ name ]
Show Details 1.0 no

Parameters
String name The name of the HTTP header
String value The value to remove

resetClientFramework() : void
Restores the use of the default client framework (using the Jaxer.Config settings), undoing any previous calls to setClientFramework().
No Details 1.0 no
setClientFramework([String src,] [String contents]) : void
Overrides the automatic injection of the client framework into the response page. If neither src nor contents are given, then NO client framework is injected into the page. Make sure you do not rely (implicitly or explicitly) on the presence of the default Jaxer client framework if you call this method!
Show Details 1.0 no

Parameters
String src (optional)The url of the alternate client framework to use, if any. If this src argument is given, any contents argument will not be used.
String contents (optional)The contents of the script block to use as an alternate client framework. If a src argument is specified, the contents argument will not be used.

setContents(String contents) : void
Sets the contents (body) of the response. Once the response's contents are set this way, the DOM is no longer serialized into the response contents at the end of page processing.
Show Details 1.0 no

Parameters
String contents The new contents to use.

setNoCacheHeaders() : void
Sets headers on this response to mark it as a dynamic one and avoid its being cached. This will always be called by the framework during callback processing. For regular (non-callback) requests, this will only be called by the framework if the DOM has been changed or a side-effect has (or could have) occurred during the processing of this request and the generation of the response.
No Details 1.0 no
statusCodeToReasonPhrase(Number statusCode) : void
Returns the standard W3C reason phrase for the given standard status code. For example, passing in 200 returns "OK", and passing in 404 returns "Not Found".
Show Details 1.0 no

Parameters
Number statusCode The status code, as an integer (or a string that can be parsed to an integer). If this is not a recognized status code, "Unknown Status Code" is returned.

wasErrorShown() : Boolean
True if an error has already been reported in the output page so it need not be reported in the output page again.
Show Details 1.0 no

Returns
Boolean True if notifyErrorShown() was called in this response, false otherwise.

aptana_docs