AnsweredAssumed Answered

Probulem JavaScript API processTemplate

Question asked by sugai on Aug 23, 2007
Latest reply on Oct 11, 2007 by kevinr
:( Hi,

I could use the JavaScript API processTemplate on the Alfresco-community-tomcat-1.4.0 and 2.0.0.
Now, I have installed the Alfresco-community-tomcat-2.1.0.
The following script can not execute on Alfresco, only 2.1.0.

Input form

<html>
<head>
<title>***** ex_listDocsSpace.html *****</title>
</head>
<body>
<form method="POST" action="http://vaio-sugai:8080/alfresco/command/script/execute" accept-charset="UTF-8" >
<br>JavaScript call from HTML form<br>
<br>
<input type="text" name="scriptPath" size="100" value="/Company Home/User Homes/ex_listDocsSpace.js">
<br><br>
<input type="text" name="spacePath" size="100" value="User Homes">
<br><br>
<input type="text" name="templatePath" size="100" value="User Homes/ex_listDocsSpace.ftl">
<br><br>
<input type="submit">
</form>
</body>
</html>

[JavaScript code]

var arg = new Array();
arg = args;
var script = arg["scriptPath"];
var spacePath = arg["spacePath"];
var templatePath = arg["templatePath"];

var result = "args check !" + "<br>";
result +=  "arg[script] : "  + script + "<br>";
result +=  "arg[spacePath] : "  + spacePath + "<br>";
result +=  "arg[templatePath] : "  + templatePath + "<br><br>";   // 10

space = userhome;
var spaceNode = space.childByNamePath(spacePath);
if ( spaceNode == null) {
     result +=  "spaceNode not found !" + "<br>";
} else {
     result += "spaceNode.name = " + spaceNode.name + "<br>";
}

// Get templateNode
var templateNode = space.childByNamePath(templatePath);
result += "templateNodeName = " + templateNode.name + "<br>";

// set spaceNode to current space
space = spaceNode;
// Execute processTemplate
var outString = new String("");
outString +=  space.processTemplate(templateNode);
result += outString + "<br>";                  
result;

[Template]

<#– Renders list of all the documents in the Space –>
<table>
<#list space.children as child>
    <#if child.isDocument>
       <tr><td>${child.properties.name}</td></tr>
    </#if>
</#list>
</table>
    system error messages

    org.alfresco.error.AlfrescoRuntimeException: Error during command servlet processing: Failed to execute script 'workspace://SpacesStore/90f0221e-5142-11dc-a12e-7f4bdf46ace9': Failed to execute script 'workspace://SpacesStore/90f0221e-5142-11dc-a12e-7f4bdf46ace9': Wrapped org.alfresco.service.cmr.repository.TemplateException (AlfrescoScript#28 )
    caused by:
    org.alfresco.service.cmr.repository.ScriptException: Failed to execute script 'workspace://SpacesStore/90f0221e-5142-11dc-a12e-7f4bdf46ace9': Failed to execute script 'workspace://SpacesStore/90f0221e-5142-11dc-a12e-7f4bdf46ace9': Wrapped org.alfresco.service.cmr.repository.TemplateException (AlfrescoScript#28 )
    caused by:
    org.alfresco.service.cmr.repository.ScriptException: Failed to execute script 'workspace://SpacesStore/90f0221e-5142-11dc-a12e-7f4bdf46ace9': Wrapped org.alfresco.service.cmr.repository.TemplateException (AlfrescoScript#28 )
    caused by:
    org.alfresco.error.AlfrescoRuntimeException: Wrapped org.alfresco.service.cmr.repository.TemplateException (AlfrescoScript#28 )
    caused by:
    org.mozilla.javascript.WrappedException: Wrapped org.alfresco.service.cmr.repository.TemplateException (AlfrescoScript#28 )
    caused by:
    org.alfresco.service.cmr.repository.TemplateException
    caused by:
    java.lang.NullPointerException
My PC is running Windows XP Home Edition Version 2002 Service Pack 2.
Are there any changes ?
Please advice me.

Outcomes