cancel
Showing results for 
Search instead for 
Did you mean: 

Importing a script into a webscript

hpalma
Champ in-the-making
Champ in-the-making
I have a webscript "search.get.js" in which i'd like to import a javascript file that is either on the repository or the classpath, doesn't really matter.

I've tried both the sintax:

<import resource="/Company Home/Data Dictionary/Scripts/myscript.js"/>

that works just fine in the javascript files, and the syntax:

<import resource="classpath:alfresco/templates/webscripts/myscript.js"/>

None of them work. I never get the functions defined in the script imported.
Any ideas ?
3 REPLIES 3

sbuckle
Champ in-the-making
Champ in-the-making
Try this:  <import resource="classpath:/alfresco/templates/webscripts/myscript.js">

Notice the additional slash in front of 'alfresco'.

hpalma
Champ in-the-making
Champ in-the-making
Try this:  <import resource="classpath:/alfresco/templates/webscripts/myscript.js">

Notice the additional slash in front of 'alfresco'.

Thanks, but it still doesn't work  :cry:

boxie
Champ in-the-making
Champ in-the-making
I have the same problem. pleeeeeeeeeeeeease reply to this and help us alfresco users out!

I want to use the json utilities from the YUI code, so i put the YUI code in /Alfresco/tomcat/webapps/alfresco/yui
the file i want to import is /Alfresco/tomcat/webapps/alfresco/yui/json/json.js

my code (first line of my …get.js file)
<import resource="classpath:alfresco/yui/json/json.js">

i tried
<import resource="classpath:/alfresco/yui/json/json.js">
too


both of these give the same results, which is a null pointer exception.

{ "status" : { "code" : 500, "name" : "Internal Error", "description" : "An error inside the HTTP server which prevented it from fulfilling the request." }, "message" : "02010026 Wrapped Exception (with status template): 02010031 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/Algonquin\/SiteDashboard\/document-library-listing\/document-library-listing.get.js': null", "exception" : "org.springframework.extensions.webscripts.WebScriptException - 02010026 Wrapped Exception (with status template): 02010031 Failed to execute script 'classpath*:alfresco\/templates\/webscripts\/Algonquin\/SiteDashboard\/document-library-listing\/document-library-listing.get.js': null", "callstack" : [ "" ,"java.lang.NullPointerException" ,"org.alfresco.repo.jscript.RhinoScriptProcessor.loadScriptResource(RhinoScriptProcessor.java:324)" ,"org.alfresco.scripts.ScriptResourceHelper.recurseScriptImports(ScriptResourceHelper.java:144)" ,"org.alfresco.scripts.ScriptResourceHelper.resolveScriptImports(ScriptResourceHelper.java:60)"