AnsweredAssumed Answered

Using 'import' clause within a webscript controller in a jar

Question asked by franco_valente on Oct 31, 2011
Latest reply on Nov 28, 2011 by erikwinlof
Hi,
I want to override existing web-tier scripts "/components/workflow/start" and package it into a jar extension.
I modified the workflow.lib.js library included in the controller start-workflow.get.js:
<import resource="classpath:alfresco/site-webscripts/org/alfresco/components/workflow/workflow.lib.js">
model.workflowDefinitions = getWorkflowDefinitions();
I have this file structure that I create a jar from:
alfresco/web-extension/site-webscripts/org/alfresco/components/workflow/workflow.lib.js
META-INF/share-config-custom.xml

Packaging this into a jar, the resource workflow.lib.js is not imported (the original file is taken instead). Why?
Does the "classpath" in the javascript controller not refers to jar resources?

I also tried overriding start-workflow.get.js and generated a jar with this file structure:
alfresco/web-extension/site-webscripts/org/alfresco/components/workflow/workflow.lib.js
alfresco/web-extension/site-webscripts/org/alfresco/components/workflow/start-workflow.get.js
META-INF/share-config-custom.xml

.. but nothing!

I tried to import another js file too..:
<import resource="classpath:alfresco/site-webscripts/org/alfresco/components/workflow/custom-workflow.lib.js">
model.workflowDefinitions = getWorkflowDefinitions();
jar structure:
alfresco/web-extension/site-webscripts/org/alfresco/components/workflow/custom-workflow.lib.js
alfresco/web-extension/site-webscripts/org/alfresco/components/workflow/start-workflow.get.js
META-INF/share-config-custom.xml

But this generated a NullPointerException…

Obviously the workaround was to include all the library code into the start-workflow.get.js file, removing the "import" clause, but… that was not very nice!

Any advice?

Outcomes