General Interface is an open source project hosted by the Dojo Foundation

Setting CDF record ID in OnBeforeDeserialize

The following function is used to set the XML id and record id on a CDF component in the OnBeforeSerialize XML code. This can prevent getting NULL object errors when trying to set the CDF record id on complex screens in the OnAfterDeserialize code area. The code is setup to be included in a package titled "utils", change the package name on the declaration line to add it to any other package.

setCDFValues
/**
 * Set CDF object XML Id and CDF ID in XML text.
 * @param objXML {Object} XML object to be changed.
 * @param strCDFName {String} Name of the CDF object to be changed
 * @param strCacheName {String} Name of the new cache document to be set on the CDF object.
 * @param redId {int} ID of the record to be set on the CDF Id..
 */
utils.setCDFValues = function(objXML, strCDFName, strCacheName, recId) {
  try {
    var strPath = '//jsx1:object[@type="jsx3.gui.CDF" and jsx1:strings[@jsxname="' + strCDFName + '"]]';
    var objCDFNode = objXML.selectSingleNode(strPath);
    if (objCDFNode) {
      objCDFNode.selectSingleNode('jsx1:strings').setAttribute("jsxxmlid", strCacheName);
      objCDFNode.selectSingleNode('jsx1:strings').setAttribute("jsxcdfid", recId);
      var objParent = objCDFNode.getParent();
      objParent.removeChild(objCDFNode);
      objParent.appendChild(objCDFNode);
    }
  } catch(e) {
    throw jsx3.lang.NativeError.wrap(e);
  }
}
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.