Hi there, we are seeing errors generated in our production application using Smartclient 12.1 because there are a series of functions that are not checking to ensure that record is not null in ISC_Grids.js for the methods below related to embedded components. There is one method below (getRecordComponents) that does check for a null record. But, the others below do not. We can add patches for all of these on our own. But, I'm just trying to be a good neighbor and recommending you add these simple checks to your code. Sorry, I do not have time to provide test cases for all of these. So, if you choose to ignore my help, that's your prerogative
Code:
_setExpanded : function (record, value) {
record[this._$expandedPrefix + this.ID] = value;
},
_getExpandedRows : function () {
return this.data.findAll(this._$expandedPrefix + this.ID, true);
},
_$hasExpansionComponentPrefix:"_hasExpansionComponent_",
_hasExpansionComponent : function (record) {
return record[this._$hasExpansionComponentPrefix + this.ID];
},
_setExpansionComponent : function (record, value) {
record[this._$hasExpansionComponentPrefix + this.ID] = value;
},
_$embeddedComponentsPrefix:"_embeddedComponents_",
_hasEmbeddedComponents : function (record) {
var ids = record[this._$embeddedComponentsPrefix + this.ID];
return (ids != null && ids.length > 0);
},
_getEmbeddedComponents : function (record) {
// Convert array of IDs into an array of component references
var ids = record[this._$embeddedComponentsPrefix + this.ID],
components = []
;
if (!ids) return null;
for (var i = 0; i < ids.length; i++) {
components[i] = isc.Canvas.getById(ids[i]);
}
return components;
},
_setEmbeddedComponents : function (record, value) {
record[this._$embeddedComponentsPrefix + this.ID] = value;
},
_addEmbeddedComponent : function (record, component) {
if(!record[this._$embeddedComponentsPrefix + this.ID]) {
record[this._$embeddedComponentsPrefix + this.ID] = [];
}
if (!record[this._$embeddedComponentsPrefix + this.ID].contains(component.getID())) {
record[this._$embeddedComponentsPrefix + this.ID].add(component.getID());
}
},
_removeEmbeddedComponent : function (record, component) {
var ids = record[this._$embeddedComponentsPrefix + this.ID];
if (ids == null) return;
if (ids.length == 0) {
record[this._$embeddedComponentsPrefix + this.ID] = null;
return;
}
ids.remove(component.getID());
if (ids.length == 0) {
record[this._$embeddedComponentsPrefix + this.ID] = null;
}
},
_deleteEmbeddedComponents : function (record, value) {
delete record[this._$embeddedComponentsPrefix + this.ID];
},
_$recordComponentsPrefix:"_recordComponents_",
_hasRecordComponents : function (record) {
return (record && record[this._$recordComponentsPrefix + this.ID] != null);
},
_getRecordComponents : function (record) {
if (!record) return null;
// Convert array of IDs into an array of component references
var ids = record[this._$recordComponentsPrefix + this.ID],
components = {}
;
if (ids) {
for (var key in ids) {
if (ids[key].isNullMarker) {
components[key] = ids[key];
} else {
components[key] = isc.Canvas.getById(ids[key]);
}
}
}
return components;
},
_addRecordComponent : function (record, fieldName, component) {
if(!record[this._$recordComponentsPrefix + this.ID]) {
record[this._$recordComponentsPrefix + this.ID] = {};
}
if (component.isNullMarker) {
record[this._$recordComponentsPrefix + this.ID][fieldName] = component;
} else {
record[this._$recordComponentsPrefix + this.ID][fieldName] = component.getID();
}
},
_deleteRecordComponent : function (record, fieldName) {
var ids = record[this._$recordComponentsPrefix + this.ID];
if (ids == null) return;
if (isc.isAn.emptyObject(ids)) {
record[this._$recordComponentsPrefix + this.ID] = null;
return;
}
// Not per-cell - just use the special "no field" fieldName
if (fieldName == null) fieldName = this._$noFieldString;
delete ids[fieldName];
if (isc.isAn.emptyObject(ids)) {
record[this._$recordComponentsPrefix + this.ID] = null;
}
},
Comment