问题描述
我正在尝试使用alfresco share扩展模块覆盖组件\node-details的javascript控制器node-header.js
I am trying to override the javascript controller node-header.js of components\node-details with the extension module of alfresco share
这是我的node- header.get.js
This is my node-header.get.js
<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">
for (var i=0; i<model.widgets.length; i++)
{
if (model.widgets[i].id == "NodeHeader")
{
if(model.widgets[i].options.nodeRef!=null)
{
var jsNode = new Alfresco.util.Node(model.widgets[i].options.nodeRef);
if(jsNode.hasAspect("custom:intranetFile")){
model.widgets[i].options.showFavourite = false;
model.widgets[i].options.showLikes = false;
}
}
}
}
I出现此错误
此行中存在错误
var jsNode = new Alfresco.util.Node(model.widgets[i].options.nodeRef);
由于Alfresco对象不可用,我该如何获取?
as Alfresco object is not available how can I get it?
推荐答案
基于我的 列表:
Based on my answer yesterday on the share-extras-devel list:
您的问题是您正在将Web脚本JS与客户端JavaScript混合使用。 Alfresco.util.Node
是客户端帮助程序类,因此可用于在网络浏览器中运行的客户端JS,但不适用于在以下位置运行的Web脚本代码
Your issue is that you are mixing up your web script JS with client-side JavaScript. Alfresco.util.Node
is a client-side helper class and is therefore available to client-side JS running in the web browser, but not to your web script code which runs on the server.
如果您查看包含的 alfresco-util.js
的源代码,会看到那里有一个帮助器类,但它称为 AlfrescoUtil
。
If you look at the source of alfresco-util.js
, which you are including, you will see that there is a helper class there but it is called AlfrescoUtil
.
要获取有关此给定值的一些信息节点,我建议您使用该类的静态方法 AlfrescoUtil.getNodeDetails()
,例如
To get some information on this given node I would suggest that you want to use the static method AlfrescoUtil.getNodeDetails()
from that class, e.g.
var jsNode = AlfrescoUtil.getNodeDetails(model.widgets[i].options.nodeRef);
jsNode
对象的结构为根据doclist-v2网络脚本返回的JSON,因此您应该能够在 aspects
array属性中检查自定义方面的存在。
The structure of the jsNode
object will be as per the JSON returned by the doclist-v2 webscripts, so you should be able to check for the presence of your custom aspect in the aspects
array property.
如果检查 alfresco-util.js
的来源,您会看到也支持其他参数getNodeDetails()
。在我看来,您还可以输入可选的网站名称,如果需要的话,还可以添加一些选项。
If you check the source of alfresco-util.js
you will see that additional parameters are also supported by getNodeDetails()
. It seems to me you can also pass in an optional site name, plus some options if you wish.
这篇关于Alfresco对象在Alfresco共享的扩展模块中不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!