2013-06-12 59 views
1

我在做这样的事情:Alfresco JavaScript - 如何获取节点属性的允许值列表?

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允许的节点属性值”和类似的查询没有给我什么。

+0

JS在哪里运行?露天回购?共享层?网页浏览器? – Gagravarr

+0

脚本是'/ Data Dictionary/Scripts /'下的回购文件。当新文档上传到空间时,它在某些空间作为内容规则操作执行。对不起,一开始就不够清楚,希望现在好一点。 – slaweet

回答

1

为了得到这一类的信息,你必须使用DictionaryService得到PropertyDefinition

关闭我的头顶,你会想要做的事,如:

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

这将在Java中,请参阅this blog post以了解有关如何使用JavaScript中的DictionaryService的详细信息

相关问题