Packages not defined

陌路散爱 提交于 2020-01-03 06:27:12

问题


i wrote a script in javascript and used it in rules (share). The script start with:

var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();

I m getting an error telling me that "Reference error: Packages is not defined".

How can i solve this issue?


回答1:


The Packages object is only available for code which is considered "secure". This is most likely failing because the code is from a node in the Repository/Data-Dictionary. Put it somewhere in the classpath (e.g. classes/alfresco/templates/webscripts/...).




回答2:


I don't think you can use this object in javascript, you won't find that code anywhere in Share javascript files. According to this link, Package root scope object is only available for web script implementations placed into the Java classpath, due to security reasons.

Try writing Java code for your rule.



来源:https://stackoverflow.com/questions/24674379/packages-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!