if (!window.Prima) Prima=[];
if (!Prima.XML) Prima.XML=[];
Prima.XML.Table = Active.XML.Table.subclass();
Prima.XML.Table.create = function()
{
var obj = this.prototype;
var _super = this.superclass.prototype;
// define a response for the table
var defaultResponse = _super.response;
obj.response = function(xml)
{
var responseCode = this._http.status;
if(responseCode == 200)
{
defaultResponse.call(this,xml);
}
else if(responseCode >= 400 && responseCode < 500)
{
alert("<bean:message key='error.httpclientresponseerror'/>" + this._http.status);
defaultResponse.call(this, xml);
}
else if(responseCode >=500 && responseCode < 600)
{
alert("<bean:message key='error.httpserverresponseerror'/>" + this._http.status);
defaultResponse.call(this, xml);
}
else
{
alert("<bean:message key='error.httpnetworkerror'/>" + this._http.status);
defaultResponse.call(this, xml);
}
}
};
Prima.XML.Table.create();
// define error codes
table.getErrorCode = function(){
var responseCode = this._http.status;
return responseCode == 200 ? 0 : responseCode;
}
// define error messages
table.getErrorText = function(){
var errorCode = this.getErrorCode();
if(errorCode >= 400 && errorCode < 500) {
return "<bean:message key='error.httpclientresponseerror'/>" + errorCode;
}
else if(errorCode >=500 && errorCode < 600) {
return "<bean:message key='error.httpserverresponseerror'/>" + errorCode;
}
else {
return "<bean:message key='error.httpnetworkerror'/>" + errorCode;
}
}
// status code
obj.setStatusProperty("code", function(){
var data = this.getDataModel();
if (!data.isReady()) {
return "loading";
}
if (data.getErrorCode()) {
return "error";
}
if (!this.getRowProperty("count")) {
return "nodata";
}
return "";
});
// define custom template logic
obj.setTemplate("main", function(){
switch (this.getStatusProperty("code")) {
case "":
return this.getDataTemplate();
case "error":
return this.getErrorTemplate();
default:
return this.getStatusTemplate();
}
});
// define custom error codes
obj.setErrorProperty("code", function(){
return this.getDataProperty("errorCode");
});
// define custom error messages
obj.setErrorProperty("text", function(){
return this.getDataProperty("errorText");
});
obj.setTemplate("error", myErrorTemplate);
This topic is archived.