creating a new space using webscripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2009 06:57 AM
I'm following a tutorial at http://drquyong.com/myblog/?p=5… Actually this is a very good tutorial for beganers.
This is really a simple UI which illustrates most ways…
This ui allows only for creating the small text documents only.
Now i want to provide an option like "Create a Space", if the user clicks on this i want to display a form where the user can fill the details like name,desc,title for the space. for that i have added a new link in DocumentList.get.html.ftl like
Create a Space <img src="${url.context}/images/icons/folder.gif" onClick="createSpace();"/></b> </tr>
and cretaeSpace java script is
var sdlg;function createSpace() { document.getElementById("space_label").innerHTML='Create Space'; document.forms['space_new'].action = '${url.serviceContext}/simpleui/document/createSpace'; sdlg.show(); }
and space_new form is,
<div dojoType="dialog" id="SpaceDialog" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"> <form name="space_new" action="" method="post"> <table> <tbody> <tr> <th colspan="2"><b><div id="space_label"></div></b></th> </tr> <tr> <td>Name</td> <td><input id="space_name" name="sn" type="text"></td> </tr> <tr> <td>Title</td> <td><input id="space_title" name="st" type="text"></td> </tr> <tr> <td>Description</td> <td><input id="space_description" name="sd" type="text" size="60"></td> </tr> <tr> <td colspan="2" align="center"> <INPUT type="hidden" id="file_noderef" name="noderef" value=""/> <INPUT type="submit" value="Create"> <input type="button" id="hider2" value="Cancel" onClick="sdlg.hide()"></td> </tr> </tbody> </table> </form> </div>
and my FolderCreate.post.js is
// Client has requested server-side action// Client has requested server-side action/* Inputs *//* Outputs */var resultString = "Action failed", resultCode = false; resultString = "Could not create space"; var spaceName = args.sn, spaceTitle = (args.st == "undefined") ? "" : args.st, spaceDescription = (args.sd == "undefined") ? "" : args.sd, var nodeNew; if ((spaceName == null) || (spaceName == "")) { resultString = "Space must have a Name"; } else { var nodeParent = roothome.childByNamePath("/Company Home/User Homes/Demo" + spaceName); nodeNew = nodeParent.createFolder(spaceName); // Always add title & description, default icon nodeNew.properties["cm:title"] = spaceTitle; nodeNew.properties["cm:description"] = spaceDescription; nodeNew.properties["app:icon"] = "space-icon-default"; nodeNew.save(); // Add uifacets aspect for the web client nodeNew.addAspect("app:uifacets"); if (nodeNew != null) { resultString = "New space created"; resultCode = true; } } model.resultString = resultString;model.resultCode = resultCode;
and my FolderCreate.desc.xml is
<webscript> <shortname>Create Space</shortname> <description>Create a space to store info from Teamworks</description> <url format="html" template="/simpleui/document/createSpace?n={nodeId}&sn={spaceName}&st={spaceTitle?}&sd={spaceDescription?}" /> <authentication>user</authentication></webscript>
my problem is i'm passing 3 variables like space name, space title, descrption in the spaceCreate form.
and i'm getting the following error in browser.
The Web Script /alfresco/service/simpleui/document/createSpace has responded with a status of 500 - Internal Error.500 Description: An error inside the HTTP server which prevented it from fulfilling the request. Message: Wrapped Exception (with status template): Failed to execute script '/alfresco/demo/simpleui/FolderCreate.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': missing variable name (AlfrescoScript#17) Exception: org.mozilla.javascript.EvaluatorException - missing variable name (AlfrescoScript#17) org.mozilla.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:109) org.mozilla.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:96) org.mozilla.javascript.Parser.addError(Parser.java:140) org.mozilla.javascript.Parser.reportError(Parser.java:154) org.mozilla.javascript.Parser.mustMatchToken(Parser.java:240) org.mozilla.javascript.Parser.variables(Parser.java:1260) org.mozilla.javascript.Parser.statementHelper(Parser.java:1057) org.mozilla.javascript.Parser.statement(Parser.java:655) org.mozilla.javascript.Parser.parse(Parser.java:377) org.mozilla.javascript.Parser.parse(Parser.java:315) org.mozilla.javascript.Context.compileImpl(Context.java:2320) org.mozilla.javascript.Context.compileString(Context.java:1348) org.mozilla.javascript.Context.compileString(Context.java:1337) org.mozilla.javascript.Context.evaluateString(Context.java:1193) org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:390) org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:122) org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:263) org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:108) org.alfresco.web.scripts.AbstractWebScript.executeScript(AbstractWebScript.java:800) org.alfresco.web.scripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:90) org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:319) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320) org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:368) org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:390) org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:273) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:261) org.alfresco.web.scripts.AbstractRuntime.executeScript(AbstractRuntime.java:139) org.alfresco.web.scripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) java.lang.Thread.run(Thread.java:595) Exception: org.alfresco.error.AlfrescoRuntimeException - missing variable name (AlfrescoScript#17) org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:406) Exception: org.alfresco.scripts.ScriptException - Failed to execute script '/alfresco/demo/simpleui/FolderCreate.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': missing variable name (AlfrescoScript#17) org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:126) Exception: org.alfresco.web.scripts.WebScriptException - Wrapped Exception (with status template): Failed to execute script '/alfresco/demo/simpleui/FolderCreate.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': missing variable name (AlfrescoScript#17) org.alfresco.web.scripts.AbstractWebScript.createStatusException(AbstractWebScript.java:595) Server: Alfresco Labs v3.0.0 (Stable 1526) schema 1,002Time: Jun 29, 2009 4:29:02 PM
The full DocumentList.get.html.ftl is,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head> <title>Alfresco Simple UI</title> <script type="text/javascript"> var djConfig = { isDebug: true ,debugAtAllCosts: true }; </script> <script type="text/javascript" src="${url.context}/scripts/ajax/dojo/dojo.js"></script> <script type="text/javascript"> dojo.require("dojo.widget.FilteringTable"); dojo.require("dojo.widget.InlineEditBox"); dojo.require("dojo.widget.Dialog"); dojo.require("dojo.event.*"); dojo.hostenv.writeIncludes(); var dlg,previewdlg,removedlg; function init(e) { dlg = dojo.widget.byId("DialogContent"); previewdlg = dojo.widget.byId("DialogPreview"); removedlg = dojo.widget.byId("DialogRemove"); sdlg = dojo.widget.byId("SpaceDialog"); } dojo.addOnLoad(init); function populate(id,noderef) { document.getElementById("file_label").innerHTML='Edit File'; document.forms['edit_new_form'].action = '${url.serviceContext}/simpleui/document/save'; document.getElementById("file_name").value=document.getElementById("name_"+id).innerHTML; document.getElementById("file_description").value=document.getElementById("desc_"+id).innerHTML; document.getElementById("file_body").value=document.getElementById("body_"+id).innerHTML; document.getElementById("file_noderef").value=noderef; dlg.show(); } function populatepreview(id) { document.getElementById("preview_name").innerHTML=document.getElementById("name_"+id).innerHTML; document.getElementById("preview_body").innerHTML=document.getElementById("body_"+id).innerHTML; previewdlg.show(); } function populateremove(id,noderef) { document.getElementById("remove_name").value=document.getElementById("name_"+id).innerHTML; document.getElementById("remove_noderef").value=noderef; removedlg.show(); } function create() { document.getElementById("file_label").innerHTML='Create File'; document.forms['edit_new_form'].action = '${url.serviceContext}/simpleui/document/create'; dlg.show(); } function createSpace() { document.getElementById("file_label").innerHTML='Create Space'; document.forms['space_new'].action = '${url.serviceContext}/simpleui/document/createSpace'; sdlg.show(); } </script> <style type="text/css"> /*** The following is just an example of how to use the table. You can override any class names to be used if you wish. ***/ table { font-family:Lucida Grande, Verdana; font-size:0.8em; width:100%; border:1px solid #ccc; border-collapse:collapse; cursor:default; } table td, table th{ padding:2px; font-weight:normal; } table thead td, table thead th { background-image:url(${url.context}/images/dojo/ft-head.gif); background-repeat:no-repeat; background-position:top right; } table thead td.selectedUp, table thead th.selectedUp { background-image:url(${url.context}/images/dojo/ft-headup.gif); } table thead td.selectedDown, table thead th.selectedDown { background-image:url(${url.context}/images/dojo/ft-headdown.gif); } table tbody tr td{ border-bottom:1px solid #ddd; } table tbody tr.alt td{ background: #e3edfa; } table tbody tr.selected td{ background: yellow; } table tbody tr:hover td{ background: #a6c2e7; } table tbody tr.selected:hover td{ background:#ff9; } #inputArea{ margin:1em 0; padding:1em; background-color:#eef; } #updateTestInput{ border:1px solid #ccc; width:100%; height:80px; font-family:serif; font-size:0.9em; overflow:auto; } .bar a img { border:0; vertical-align: middle; } .dojoDialog { background : #eee; border : 1px solid #999; -moz-border-radius : 5px; padding : 4px; width: 80% } .footer { text-align: center; position:absolute; font-family:Lucida Grande, Verdana; font-size:0.8em; bottom:10px; left: 35% } </style></head><body> <div dojoType="dialog" id="DialogPreview" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"> <table> <tbody> <tr> <th><b>Previw File </b><div id="preview_name"></div></th> </tr> <tr> <td><div id="preview_body"></div></td> </tr> <tr> <td align="center"><input type="button" id="hide3" value="Close" onClick="previewdlg.hide()"></td></td> </tr> </tbody> </table> </div> <div dojoType="dialog" id="DialogRemove" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"> <form name="remove_form" action="${url.serviceContext}/simpleui/document/remove" method="post"> <table> <tbody> <tr> <th><b>Remove File </b><INPUT type="text" id="remove_name" name="name" value="" disabled/></th> </tr> <tr> <td>Do you really really really want to delete this file?</td> </tr> <tr> <td align="center"> <INPUT type="hidden" id="remove_noderef" name="noderef" value=""/> <INPUT type="hidden" id="remove_name" name="name" value=""/> <input type="submit" value="Ok"/> <input type="button" id="hide3" value="Cancel" onClick="removedlg.hide()"></td></td> </tr> </tbody> </table> </form> </div> <div dojoType="dialog" id="DialogContent" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"> <form name="edit_new_form" action="" method="post"> <table> <tbody> <tr> <th colspan="2"><b><div id="file_label"></div></b></th> </tr> <tr> <td>Name</td> <td><input id="file_name" name="name" type="text"></td> </tr> <tr> <td>Description</td> <td><input id="file_description" name="desc" type="text" size="60"></td> </tr> <tr> <td valign="top">Body</td> <td><textarea id="file_body" name="body" rows="10" cols="60"></textarea></td> </tr> <tr> <td colspan="2" align="center"> <INPUT type="hidden" id="file_noderef" name="noderef" value=""/> <INPUT type="submit" value="Save"> <input type="button" id="hider2" value="Cancel" onClick="dlg.hide()"></td> </tr> </tbody> </table> </form> </div><div dojoType="dialog" id="SpaceDialog" bgColor="gray" bgOpacity="0.5" toggle="fade" toggleDuration="250" closeOnBackgroundClick="true"> <form name="space_new" action="" method="post"> <table> <tbody> <tr> <th colspan="2"><b><div id="space_label"></div></b></th> </tr> <tr> <td>Name</td> <td><input id="space_name" name="sn" type="text"></td> </tr> <tr> <td>Title</td> <td><input id="space_title" name="st" type="text"></td> </tr> <tr> <td>Description</td> <td><input id="space_description" name="sd" type="text" size="60"></td> </tr> <tr> <td colspan="2" align="center"> <INPUT type="hidden" id="file_noderef" name="noderef" value=""/> <INPUT type="submit" value="Create"> <input type="button" id="hider2" value="Cancel" onClick="sdlg.hide()"></td> </tr> </tbody> </table> </form> </div> <h3>Simple Alfresco User Interface</h3> <h4>Hello ${person.properties.firstName}!</h4> <tr> <b>Create a File <img src="${url.context}/images/icons/add.gif" onClick="create();"/> Create a Space <img src="${url.context}/images/icons/folder.gif" onClick="createSpace();"/></b> </tr> <table dojoType="filteringTable" id="documentList" alternateRows="true" maxSortable="2" cellpadding="0" cellspacing="0" border="0"> <thead> <tr> <th field="Name" dataType="String" sort="asc" valign="top">Name</th> <th field="DateAdded" dataType="DateTime" align="center" valign="top">Created</th> <th field="DateModified" dataType="DateTime" align="center" valign="top">Modified</th> <th dataType="html">Description</th> <th dataType="html">Body</th> <th dataType="html">Actions</th> </tr> </thead> <tbody> <#list resultset as node> <tr value="${node_index + 1}"> <td><div id="name_${node_index + 1}">${node.name}</div></td> <td>${node.properties.created?datetime}</td> <td>${node.properties.modified?datetime}</td> <td><div id="desc_${node_index + 1}">${node.properties.description}</div></td> <td><div id="body_${node_index + 1}">${node.content}</div></td> <td> <div class="bar"> <a href="#" onClick="populatepreview('${node_index + 1}')"><img src="${url.context}/images/icons/preview.gif"/></a> <a href="#" onClick="populate('${node_index + 1}','${node.nodeRef}')"><img src="${url.context}/images/icons/edit_icon.gif"/></a> <a href="${url.serviceContext}/api/node/content/${node.nodeRef.storeRef.protocol}/${node.nodeRef.storeRef.identifier}/${node.nodeRef.id}/${node.name?url}"><img src="${url.context}/images/icons/CheckOut_icon.gif"/></a> <a href="#" onClick="populateremove('${node_index + 1}','${node.nodeRef}')"><img src="${url.context}/images/icons/delete.gif"/></a> </div> </td> </tr> </#list> </tbody> </table> <div class="footer"> Alfresco. © 2009-2010 All rights reserved. </div></body></html>
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2009 12:15 AM
please respond!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2009 02:30 AM
spaceTitle = (args.st == "undefined") ? "" : args.st,spaceDescription = (args.sd == "undefined") ? "" : args.sd,
Why do you have commas here, and in some other places too?
Cheers,
Ivan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2009 03:26 AM
Thanks for ur reply.
i removed the comas in FolderCreate.post.js… the following is my new file.
// Client has requested server-side action/* Inputs *//* Outputs */var resultString = "Action failed";var resultCode = false; resultString = "Could not create space"; var spaceName = args.sn; var spaceTitle = (args.st == "undefined") ? "" : args.st; var spaceDescription = (args.sd == "undefined") ? "" : args.sd; var nodeNew; if ((spaceName == null) || (spaceName == "")) { resultString = "Space must have a Name"; } else { var nodeParent = roothome.childByNamePath("/Company Home/User Homes/Demo" + spaceName); nodeNew = nodeParent.createFolder(spaceName); // Always add title & description, default icon nodeNew.properties["cm:title"] = spaceTitle; nodeNew.properties["cm:description"] = spaceDescription; nodeNew.properties["app:icon"] = "space-icon-default"; nodeNew.save(); // Add uifacets aspect for the web client nodeNew.addAspect("app:uifacets"); if (nodeNew != null) { resultString = "New space created"; resultCode = true; } } model.resultString = resultString;model.resultCode = resultCode;
now i'm getting the following error.
500 Description: An error inside the HTTP server which prevented it from fulfilling the request. Message: Wrapped Exception (with status template): Failed to execute script '/alfresco/demo/simpleui/FolderCreate.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': TypeError: Cannot call method "createFolder" of null (AlfrescoScript#27) Exception: org.mozilla.javascript.EcmaError - TypeError: Cannot call method "createFolder" of null (AlfrescoScript#27) org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350) org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340) org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3356) org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3375) org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3394) org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2026) org.mozilla.javascript.gen.c51._c0(AlfrescoScript:27) org.mozilla.javascript.gen.c51.call(AlfrescoScript)
any idea?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2009 04:46 AM
just follow the error code, and see what you can gather from there.
You see that you have an error on line 27, saying that it can't call a method of null. Going to your script, you'll see that line is:
nodeNew = nodeParent.createFolder(spaceName);
So, nodeParent is null. Now you know your problem lies in:
var nodeParent = roothome.childByNamePath("/Company Home/User Homes/Demo" + spaceName);
Try removing the first forward slash, and adding one before 'space name'.
Cheers,
Lista.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2009 04:59 AM
Thanks for your reply still luck is not reaching.
this is my new code..
var nodeParent = roothome.childByNamePath("Company Home/User Homes/Demo"+ spaceName);
i'm trying in this way also… but no luck
var nodeParent = roothome.childByNamePath("Company Home/User Homes/Demo"+"/"+ spaceName);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2009 03:24 AM
logger.log("spaceName value : " + spaceName);
companyhome.childByNamePath("/User Homes/Demo/" + spaceName);
(The "log" will tell you if "spaceName" is null… that could be an error)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2009 04:33 AM
Thanks for ur reply.
I made the changes according to ur suggestions.
But in log file i'm seeing the space name (which i'm tring to create)
14:07:58,178 DEBUG [org.alfresco.repo.jscript.ScriptLogger] spaceName value : material
But in browser it is showing the same error.
The Web Script /alfresco/service/simpleui/document/createSpace has responded with a status of 500 - Internal Error.500 Description: An error inside the HTTP server which prevented it from fulfilling the request. Message: Wrapped Exception (with status template): Failed to execute script '/alfresco/demo/test/simpleui/FolderCreate.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': TypeError: Cannot call method "createFolder" of null (AlfrescoScript#32) Exception: org.mozilla.javascript.EcmaError - TypeError: Cannot call method "createFolder" of null (AlfrescoScript#32) org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350) org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340) org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3356) org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3375) org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3394) org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2026) org.mozilla.javascript.gen.c23._c0(AlfrescoScript:32) org.mozilla.javascript.gen.c23.call(AlfrescoScript) org.mozilla.javascript.ContextFactory.doTopCall(
The folloiwng is my createFolder.post.js file
// Client has requested server-side action/* Inputs *//* Outputs */var resultString = "Action failed";var resultCode = false; resultString = "Could not create space"; var spaceName = args.sn; var spaceTitle = (args.st == "undefined") ? "" : args.st; var spaceDescription = (args.sd == "undefined") ? "" : args.sd; var nodeNew; if ((spaceName == null) || (spaceName == "")) { resultString = "Space must have a Name"; } else { // var nodeParent = roothome.childByNamePath("Company Home/User Homes/Demo" + spaceName); logger.log("spaceName value : " + spaceName); var nodeParent = companyhome.childByNamePath("/User Homes/Demo/" + spaceName); nodeNew = nodeParent.createFolder(spaceName); // Always add title & description, default icon nodeNew.properties["cm:title"] = spaceTitle; nodeNew.properties["cm:description"] = spaceDescription; nodeNew.properties["app:icon"] = "space-icon-default"; nodeNew.save(); // Add uifacets aspect for the web client nodeNew.addAspect("app:uifacets"); if (nodeNew != null) { resultString = "New space created"; resultCode = true; } } model.resultString = resultString;model.resultCode = resultCode;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2009 04:48 AM
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2009 05:13 AM
The actual problem is in the log file it is showing the spaceName=xxx.
But in browser i'm getting space null exception
500 Description: An error inside the HTTP server which prevented it from fulfilling the request. Message: Wrapped Exception (with status template): Failed to execute script '/alfresco/demo/test/simpleui/FolderCreate.post.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': TypeError: Cannot call method "createFolder" of null (AlfrescoScript#34) Exception: org.mozilla.javascript.EcmaError - TypeError: Cannot call method "createFolder" of null (AlfrescoScript#34) org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350) org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340) org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3356) org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3375) org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3394) org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2026)
i changed the line to
var nodeParent = companyhome.childByNamePath("Demo" + spaceName);
the following is my complete FolderCreate.post.js
// Client has requested server-side action/* Inputs *//* Outputs */var resultString = "Action failed";var resultCode = false; resultString = "Could not create space"; var spaceName = args.sn; var spaceTitle = (args.st == "undefined") ? "" : args.st; var spaceDescription = (args.sd == "undefined") ? "" : args.sd; var nodeNew; if ((spaceName == null) || (spaceName == "")) { resultString = "Space must have a Name"; } else { logger.log("spaceName value : " + spaceName); var nodeParent = companyhome.childByNamePath("Demo" + spaceName); nodeNew = nodeParent.createFolder(spaceName); // Always add title & description, default icon nodeNew.properties["cm:title"] = spaceTitle; nodeNew.properties["cm:description"] = spaceDescription; nodeNew.properties["app:icon"] = "space-icon-default"; nodeNew.save(); // Add uifacets aspect for the web client nodeNew.addAspect("app:uifacets"); if (nodeNew != null) { resultString = "New space created"; resultCode = true; } } model.resultString = resultString;model.resultCode = resultCode;
i don't know where i'm getting this null.
