简体   繁体   中英

Populating DropDown List in Alfresco Share

I need help populating dropdown list in Alfresco Share. I've created a WebScript API which I read the content of a folder in the repository. As a service in Alfresco (repository) it works. However, I need that DropDown in Share.

Here is what I did in Alfresco:

 var folder = roothome.childByNamePath(url.extension); if (folder == undefined || !folder.isContainer) { status.code = 404; status.message = "Folder " + url.extension + " not found."; status.redirect = true; } model.folder = folder; 

<webscript>
  <shortname>Folder Listing Sample</shortname>
  <description>Sample demonstrating the listing of folder contents</description>
  <url>/folder/{path}</url>
  <format default="html">argument</format>
  <authentication>user</authentication>
  <transaction>required</transaction>
</webscript>
<html>
  <head>
    <title>${folder.displayPath}/${folder.name}</title>
  </head>
  <body>
    Folder: ${folder.displayPath}/${folder.name}
    <br>
    <select id='selectItems' name='selectItems' onchange='dropdown2()'>
        <#list folder.children as child>
            <option value='${child.nodeRef}'>${child.properties.name}</option>
        </#list>
    </select>
  </body>
</html>
<#macro encodepath node><#if node.parent?exists><@encodepath node=node.parent/>/${node.name?url}</#if></#macro>

I need this dropdown in Share. Since variables like: userhome, companyhome and such aren't accessible from Share WebScripts, I don't know how to get info from Alfresco and display it in Share. Any help would be appreciated.

From javascript controller of alfresco share, you can call webscript of alfresco and retrieve details from alfresco webscript in json format. Below is one example which is calling alfresco side webscript from share javascript controller.

 try
 {

  var url = "/slingshot/webscript/from/alfresco/url";
  logger.log("url: " + url);
  // Request the current user's preferences
  var result = remote.call(url);
  if (result.status == 200 && result != "{}")
  {
     logger.log(result);
     var nodeInfo = eval('(' + result + ')');
     nodeRef = nodeInfo.parent.nodeRef;
  }
 }
 catch (e)
 {    }

In above url, is of alfresco webscript url which will return data in json format.you can also return data in another format depends on your requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM