我需要帮助填充 Alfresco Share 中的下拉列表。我创建了一个 WebScript API,它读取存储库中一个文件夹的内容。作为 Alfresco(存储库)中的一项服务,它可以工作。但是,我需要 Share 中的 DropDown。
这是我在 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>
我需要 Share 中的这个下拉菜单。由于无法从 Share WebScripts 访问 userhome、companyhome 等变量,我不知道如何从 Alfresco 获取信息并将其显示在 Share 中。任何帮助将不胜感激。
最佳答案
从 alfresco 共享的 javascript Controller ,您可以调用 alfresco 的 webscript 并以 json 格式从 alfresco webscript 检索详细信息。下面是一个从共享 javascript Controller 调用 alfresco 端 webscript 的示例。
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)
{ }
在上面的 url 中,是 alfresco webscript url,它将以 json 格式返回数据。您也可以根据需要以其他格式返回数据。
关于javascript - 在 Alfresco Share 中填充下拉列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26398609/