joe essid
joe essid

Reputation: 91

Packages not defined

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?

Upvotes: 0

Views: 2158

Answers (2)

Andreas Steffan
Andreas Steffan

Reputation: 6159

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/...).

Upvotes: 2

Miki
Miki

Reputation: 2517

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.

Upvotes: 0

Related Questions