Alfresco JavaScript - 如何获取节点属性的允许值列表?

时间:2013-06-12 09:54:25

标签: javascript alfresco

我正在做这样的事情:

document.properties["my:customProperty"] = getSomehowTheProperty(document);

my:customProperty是一个字符串,在内容模型中有一些允许的值。

如何从内容模型中获取允许的值,以便我不必将它们存储在脚本内的JavaScript数组中?

或者我如何检查函数getSomehowTheProperty是否返回了允许的值?

我尝试用try-catch包装它:

    try {
      document.properties["my:customProperty"] = getSomehowTheProperty(document);
      document.save();
    } catch (e) {
      document.properties["my:customProperty"] = "Default Value";
      document.save();
    }

但看起来完整性被检查并且在执行脚本结束时抛出错误,而不是在try块内。

谷歌搜索“alfresco js允许节点属性的值”和类似的查询没有给我任何东西。

1 个答案:

答案 0 :(得分:2)

为了获得这类信息,您必须使用DictionaryService获取PropertyDefinition

在我的头顶,你会想做类似的事情:

QName customPropertyQ = QName.createQName("my:customProperty", namespaceService);
PropertyDefinition customPropertyT = dictionaryService.getProperty(customPropertyQ);
List allowedValues = customPropertyT.getConstraints();

这是Java版本,有关如何使用JavaScript中的DictionaryService的详细信息,请参阅this blog post

相关问题