Check if the specified CDF document is empty.
Originally contributed by Kartik Sarangi
Modified Version
/* * Method to check if a Document or Document associated with a CDF control is empty or not. *@param object (Object) jsx3.app.Server or class that implements jsx3.xml.CDF *@param strCDF {String} Cache ID of document stored in application Cache *@return boolean */ isDocEmpty = function(object, strCDF) { var objXML = null; if (object.instanceOf(jsx3.app.Server) ) objXML = object.getCache().getDocument(strCDF); if (object.instanceOf(jsx3.xml.CDF) ) objXML = object.getXML(); return (objXML === null || (objXML.getFirstChild() === null)); };
Short version for in-line code.
//var objXML = matrix1.getXML(); var isDocEmpty = (objXML && objXML.getFirstChild() == null);
Or with additional check for asynch loaded document
// async loaded document with error is considered empty var isDocEmpty = (objXML && !objXML.hasError() && objXML.getFirstChild() == null);
