share-header.lib.js override doesn't work in Alfresco SDK 3.0

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Member II

share-header.lib.js override doesn't work in Alfresco SDK 3.0

Hi,

I have built a project using Alfresco SDK 3.0 and tried to override the getShareServices() in the share-header.lib.js file. I created the modified share-header.lib.js in the following directory of SDK folder sites-webscripts/

sites-webscripts/com/alfresco/share/imports/

and my extension file is like as follow

<module>

      <id>custom shareService</id>

      <version>1.0</version>

      <auto-deploy>true</auto-deploy> 

      <customizations>

        <customization>

          <targetPackageRoot>org.alfresco.share.imports</targetPackageRoot>

          <sourcePackageRoot>com.alfresco.share.imports</sourcePackageRoot>

          <alwaysApply>

       <webscript>share-header</webscript>

      </alwaysApply>

        </customization>

      </customizations>

    </module>

But the changes are not applied, though the new module is getting registered. Do I need to add anything more?

Thanks.

2 Replies
Highlighted
Master

Re: share-header.lib.js override doesn't work in Alfresco SDK 3.0

The targetPackageRoot is incorrect. You are trying to target library scripts, but the targetPackageRoot is actually meant to target the actual web scripts that render a particular page.

Also, you cannot override a function (getShareServices) using the "customization" approach. The original code will already have been run by the point your code is called. Your customisation is supposed to act like a post-processor and modify the result of the original code (in the web script model).

Highlighted
Member II

Re: share-header.lib.js override doesn't work in Alfresco SDK 3.0

I have achived same goal as below:

1) Extention model. 

<extension>
<modules>
<module>
<id>Add custom menu item to header</id>
<version>1.0</version>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
<sourcePackageRoot>org.alfresco.share.imports</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>

2) You can override your getShareServices() by updating in the share-header.lib.js

3) Place your updated share-header.lib.js in same folder where share-header.get.js and update path like this where your share-header.lib.js reside in the share-header.get.js

<import resource="classpath:/alfresco/web-extension/site-webscripts/org/alfresco/share/imports/share-header.lib.js">