cancel
Showing results for 
Search instead for 
Did you mean: 

Import another js file to webscript and autoformat code issue in eclipse.

sunquanbin
Champ on-the-rise
Champ on-the-rise
Hi everyone,

In webscript js handler, we can import another js file via:

<import resource="classpath:/alfresco/extension/templates/webscripts/org/alfresco/eLab/parse-args.lib.js">

It works fine but the only issue is I cannot use the "Auto Format Code" feature in Eclipse because that <import> is not recognised by Eclipse.

It's quite annoying to me as I currently have to comment out that line and do the auto format and then un-comment.

In addition, I'm using "JSHint" plugin to valid the code and it reports the <import> tag as an error. I knew this import only works in Alfresco, but I can I config the plugin to ignore this error?

These are non-program issues so I am not sure whether I have posted it at the correct place.

Many thanks,

Sun
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

these are known limitations with Alfresco web script or any other server-side JavaScript files.
I have <a href="http://axel-faust.de/?p=75&lang=en">blogged about this</a> in the past and even <a href="https://github.com/AFaust/alfresco-enhanced-script-environment">created a project</a> to allow an improved way to import other files without the "illegal" tag.

Unless you choose not to use import or use an addon such as mine that provides you with another, syntactically legal way to import, you won't be able to get rid of these unpleasant side-effects.

Regards
Axel

sunquanbin
Champ on-the-rise
Champ on-the-rise
Thanks Alax,

I tried to add dependency of your project AMP by adding the following (copied from your project wiki) to my pom.xml:

      <dependency>
         <groupId>org.nabucco.alfresco</groupId>
         <artifactId>org.nabucco.alfresco.enhScriptEnv.repo</artifactId>
         <version>0.0.1.0-SNAPSHOT</version>
         <type>amp</type>
         <exclusions>
            <exclusion>
               <groupId>*</groupId>
               <artifactId>*</artifactId>
            </exclusion>
         </exclusions>
      </dependency>


when I build my AMP using Maven, I received the errors:

[WARNING] 'dependencies.dependency.exclusions.exclusion.groupId' for org.nabucco.alfrescoSmiley Surprisedrg.nabucc
o.alfresco.enhScriptEnv.repo:amp with value '*' does not match a valid id pattern. @ line 54, column
15
[WARNING] 'dependencies.dependency.exclusions.exclusion.artifactId' for org.nabucco.alfrescoSmiley Surprisedrg.nab
ucco.alfresco.enhScriptEnv.repo:amp with value '*' does not match a valid id pattern. @ line 55, col
umn 18

Could you help me with this please.

Regards,
Sun