Error message template


I propose the following change to allow for an easy way to display erorr message in the grid (for example, if an error occured on the server when fetching the xml data):

1) In Grid.js, add the following inside the "Active.Controls.Grid.create" function:
obj.defineTemplate("error", new Active.HTML.DIV);

2) In list.js, replace the current "html" function with the following:
var html = function(){
var data = this.getDataModel();
// Notice that I reset the content of the error template to clear previous errors.
if (!data.isReady()) {this.getErrorTemplate().setContent("html", ""); return this.getMessageTemplate()}
if (this.getErrorTemplate().getContent("html") != "") { return this.getErrorTemplate()}
var i, result = [], temp = [], items = this.getItemsProperty("values");
for(i=0; i<items.length; i++) {result[i] = this.getItemTemplate(items[i], temp).toString()}
return result.join("");
obj.setContent("html", html);

3) Now developers can display error message like this (this sample assumes that error messages are returned from the server in a node called "error"):
var defaultResponse = table.response;
table.response = function(data){
defaultResponse.call(this, data);
var oNode = data.selectSingleNode("//error");
if (oNode != null) {
obj.getErrorTemplate().setContent(\"html\", oNode.selectSingleNode(\"html\").text);"));
April 2,
Yes, definitely good idea!
Alex (ActiveWidgets)
April 2,

This topic is archived.

See also:

Back to support forum