AnsweredAssumed Answered

Débutant en Web Scripts...

Question asked by fred_pack on Sep 30, 2009
Latest reply on Oct 1, 2009 by bertrandf
Bonjour à tous,

je me mets aux web scripts, et comme il faut bien commencer par un exemple, j'ai choisi celui-ci :

ma description : arbo.get.desc.xml

<webscript>
  <shortname>Affichage documents</shortname>
  <description>Test2</description>
  <url>/repo</url>
  <url>/repo/node/{nodeid}</url>
  <url>/repo/node/path/{path}</url>

  <format default="html">argument</format>
  <authentication>guest</authentication>
  <transaction>required</transaction>
</webscript>
mon template : arbo.get.html.flt

<#assign spaces = results.spaces>
<#assign docs = result.documents>

<html>
<body>

<b>Spaces:</b><br/>
<#list spaces as space>
<a href="${url.serviceContext}/repo/node/${space.id}">${space.name}</a><br/>
</#list>
<hr/>
<b>Documents:</b><br/>
<#list docs as doc>
<a href="$url.serviceContext}/repo/node/${doc.id}">${doc.name}</a><br/>
</#list/
<hr/>
</body>
</html>
mon javascript : arbo.get.js

<import resource="classpath:alfresco/extension/templates/webscripts/org/alfresco/util/json.js">

var curNode = companyhome;

if (url.extension != "") {

   if (url.match == "/alfresco/service/repo/node/path/") {
      var expr = "company Home/";
      var str = url.extension.replace(expr,"");
      if (str != "") {
         curNode = companyhome.childByNamePath(str);
      }
   } else if (url.match == "/alfresco/service/repo/node/") {
      curNode = search.findNode("workspace://SpaceStore/" + URL.extension);
   }
}


var children = curNode.children;
var results = {};

var numDocs = 0;
var numSpaces = 0;

results.node = curNode;
results.spaces = new Array();
results.documents = new Array();

for (var i=0; i < children.length; i++){
   var index = 0;
   if (children[i].isContainer) {
      results.spaces[numSpace] = children[i];
      index = numSpaces++;
   } else if (children[i].isDocument) {
      results.documents[numDocs] = children[i];
      index = numDocs++;
   }
}
model.results = results;

Je lance won web script : http://mon_ip:8080/alfresco/service/repo
Et la…j'ai une erreur de syntaxe, et je pédale dans la semoule pour corriger

Message:   Wrapped Exception (with status template): Failed to execute script '/maboite/arbo.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': erreur de syntaxe (AlfrescoScript#8)
   

y-aurait-il une âme charitable pour me filer un petit coup de pouce  :P

Merci de votre aide

Outcomes