##// END OF EJS Templates
initial port of implab/web
initial port of implab/web

File last commit:

r0:7110eac54b19 v1.0.0 default
r0:7110eac54b19 v1.0.0 default
Show More
ModelResponse.js
28 lines | 1.1 KiB | application/javascript | JavascriptLexer
/ src / main / js / ModelResponse.js
cin
initial port of implab/web
r0 define([ "dojo/_base/declare", "./HttpResponse" ], function(declare, HttpResponse) {
return declare(HttpResponse, {
presenter : null,
constructor : function(model, options) {
if (options && options.presenter)
this.presenter = options.presenter;
},
send : function() {
console.log("try to present: " + this.content);
if (!this.presenter)
throw "The presenter isn't specified for the model '" + this.content + "'";
if (this.statusCode != 203 && this.presenter.contentType)
this.setHeader("Content-type", this.presenter.contentType);
this.inherited(arguments);
},
writeEntity : function(serverResponse) {
if (this.statusCode == 203)
return;
serverResponse.write(this.presenter.present(this.content), this.getContentType() ? this.getContentType().parameters.charset : undefined);
}
});
});