Webscript controller : Just a misunderstood about null value

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2012 10:36 AM
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 :
And the output result is :
Can you explain me why the fourth line of output is "result=null" ?
And why "result1", "result2", "result3" is not displayed ?
Thanks
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] false16:29:08,697 DEBUG [org.alfresco.repo.jscript.ScriptLogger] false16:29:08,697 DEBUG [org.alfresco.repo.jscript.ScriptLogger] false16:29:08,697 DEBUG [org.alfresco.repo.jscript.ScriptLogger] result=null16: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
Labels:
- Labels:
-
Archive
5 REPLIES 5

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2012 08:28 AM

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2012 06:26 AM
ok thanks.
Below, another test.
Input code :
Output result (space are displayed with '_' (underscore) caracter) :
Can someone tell me the value of the "result" variable then ?
Thanks
Below, another test.
Input code :
for(var i = 0; i < categories.length; i++) { var result = connector.get("/deckshare/categoryChildren/path/"+categories[i]); if(result != null && result != "" && result != undefined) { logger.log("isEmptyTest :"); logger.log(isEmpty(result)); logger.log(result); logger.log(String(result)); var obj = eval('(' + result + ')'); //for(var j = 0; j < obj.children.length; j++) { if(childSelected(obj, nodeId)) { //obj.expanded = "true"; } //} results.push(obj); } }function isEmpty(obj) { if (typeof obj == 'undefined' || obj === null || obj === '') return true; if (typeof obj == 'number' && isNaN(obj)) return true; if (obj instanceof Date && isNaN(Number(obj))) return true; return false;}
Output result (space are displayed with '_' (underscore) caracter) :
12:22:41,461 DEBUG [org.alfresco.repo.jscript.ScriptLogger]_isEmptyTest_:12:22:41,464 DEBUG [org.alfresco.repo.jscript.ScriptLogger]_false12:22:41,464 DEBUG [org.alfresco.repo.jscript.ScriptLogger]_12:34:37,318 DEBUG [org.alfresco.repo.jscript.ScriptLogger]_null
Can someone tell me the value of the "result" variable then ?
Thanks

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2012 06:28 AM
Seems to be a string with a space: " "

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2012 06:30 AM
Sorry not… it's not a space….

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2012 06:38 AM
Yes, this is NOT a space, this is nothing.
Check again, I just have edited the code (String(result)) output added.
I don't understand this code…
Check again, I just have edited the code (String(result)) output added.
I don't understand this code…
