AnsweredAssumed Answered

Webscript controller : Just a misunderstood about null value

Question asked by zomurn on Jan 18, 2012
Latest reply on Jan 20, 2012 by zomurn
Hi,

I'am currently debugging a webscript (not of mine) turning on all debugging features for web script in alfresco, more precisely a controller named categories.get.js ; here a portion of code of it :

for(var i = 0; i < categories.length; i++) {
      var result = connector.get("/deckshare/categoryChildren/path/"+categories[i]);
      logger.log("result1"+result==null);
      logger.log("result2:"+result=='null');
      logger.log("result3:"+result=="null");
      if(result != null && result != "") {
         logger.log("result="+result);
                        …
                }
}

And the output result is :

16:29:08,697 DEBUG [org.alfresco.repo.jscript.ScriptLogger] false
16:29:08,697 DEBUG [org.alfresco.repo.jscript.ScriptLogger] false
16:29:08,697 DEBUG [org.alfresco.repo.jscript.ScriptLogger] false
16:29:08,697 DEBUG [org.alfresco.repo.jscript.ScriptLogger] result=null
16:29:08,699 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: 00180003 Failed to execute script 'org.springframework.extensions.webscripts.ResourceStore$WebApplicationStoreScriptContent@5db3f5b4': 00180002 TypeError: Cannot read property "id" from null (/WEB-INF/webscripts/categories/categories.get.js#35)
org.springframework.extensions.webscripts.WebScriptException: 00180003 Failed to execute script 'org.springframework.extensions.webscripts.ResourceStore$WebApplicationStoreScriptContent@5db3f5b4': 00180002 TypeError: Cannot read property "id" from null (/WEB-INF/webscripts/categories/categories.get.js#35)

Can you explain me why the fourth line of output is "result=null" ?
And why "result1", "result2", "result3" is not displayed ?

Thanks

Outcomes