Removing @region does not remove JS dependencies
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2013 08:57 AM
I want to customize document library page by removing some components, for example tags selector on the sidebar. However if I try to do that via Share extension and a
<blockquote>Uncaught TypeError: Cannot set property 'innerHTML' of null tag-filter_cfe8eb842c90afad615db8da193e9ce1.js:213</blockquote>
So the JavaScript of tag-filter is still there on the page, while the HTML is removed.
Seems like when it comes to executing custom freemarker overrides, a tag-filter WebScript is already evaluated, and its JavaScript (and probably CSS) dependencies are already in the model. And @region removal does not exclude them.
Does anybody know of a way to get rid of such dependencies, either via .ftl or .js overrides?
(Steps to reproduce on Alfresco 4.2:
1. Create a Share extension
2. Create a file overriding templates/org/alfresco/documentlibrary.ftl:
<@region target="tags" action="remove"/>
3. Load the document library page. The tag filter is not there, but there is an error in browser console.)
<@region target="tags" action="remove"/>
, I get a JavaScript error in browser, coming from tag-filter.js:<blockquote>Uncaught TypeError: Cannot set property 'innerHTML' of null tag-filter_cfe8eb842c90afad615db8da193e9ce1.js:213</blockquote>
So the JavaScript of tag-filter is still there on the page, while the HTML is removed.
Seems like when it comes to executing custom freemarker overrides, a tag-filter WebScript is already evaluated, and its JavaScript (and probably CSS) dependencies are already in the model. And @region removal does not exclude them.
Does anybody know of a way to get rid of such dependencies, either via .ftl or .js overrides?
(Steps to reproduce on Alfresco 4.2:
1. Create a Share extension
2. Create a file overriding templates/org/alfresco/documentlibrary.ftl:
<@region target="tags" action="remove"/>
3. Load the document library page. The tag filter is not there, but there is an error in browser console.)
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2013 05:22 AM
Hello,
I had a different issue with markups a few months back and the behavior you describe sounds like a potential consequence of the same core behaviour that tripped me up. This is <a href="https://issues.alfresco.com/jira/browse/ALF-19976">the JIRA ticket</a> I opened in September. If you read through the comments you should come to understand that any output generated by <@script> or <@link> is independant of the <@markup> (and by extension <@region>) it is contained in.
By removing the <@markup> or <@region> you remove the model of rendered elements associated with that element, but since the deferred models of <@script> and <@link> are <b>not</b> associated with their original <@markup> / <@region>, they will not be removed along with it and are still present in the output.
Now my interpretation may be flawed as there is a lot going on behind the scenes that I have not fully retraced on a code level yet. This is something that Dave Draper or Kevin Roast may be best suited to answer.
Since you can reproduce this issue please create a JIRA or - if you are an Enterprise customer or working for one - create a support ticket for this.
The only way I can think of working around this would be by using sub-component configuration instead of customization to remove the component instead of "just" the <@region>. That way, the tag-filter web script will not even be evaluated and nothing needs to be removed after it has generated some output.
Regards
Axel
I had a different issue with markups a few months back and the behavior you describe sounds like a potential consequence of the same core behaviour that tripped me up. This is <a href="https://issues.alfresco.com/jira/browse/ALF-19976">the JIRA ticket</a> I opened in September. If you read through the comments you should come to understand that any output generated by <@script> or <@link> is independant of the <@markup> (and by extension <@region>) it is contained in.
By removing the <@markup> or <@region> you remove the model of rendered elements associated with that element, but since the deferred models of <@script> and <@link> are <b>not</b> associated with their original <@markup> / <@region>, they will not be removed along with it and are still present in the output.
Now my interpretation may be flawed as there is a lot going on behind the scenes that I have not fully retraced on a code level yet. This is something that Dave Draper or Kevin Roast may be best suited to answer.
Since you can reproduce this issue please create a JIRA or - if you are an Enterprise customer or working for one - create a support ticket for this.
The only way I can think of working around this would be by using sub-component configuration instead of customization to remove the component instead of "just" the <@region>. That way, the tag-filter web script will not even be evaluated and nothing needs to be removed after it has generated some output.
Regards
Axel

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2013 05:26 AM
Hi Axel,
Thank you for your reply!
What I did as a quick workaround is just override the whole body region of documentlibrary and hide the tag-filter via CSS. This is of course not the best solution as the JS and HTML is still there on the page.
I will try with sub-component configuration as well. And raise the support ticket.
Regards,
Bulat
Thank you for your reply!
What I did as a quick workaround is just override the whole body region of documentlibrary and hide the tag-filter via CSS. This is of course not the best solution as the JS and HTML is still there on the page.
I will try with sub-component configuration as well. And raise the support ticket.
Regards,
Bulat
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2013 08:47 AM
Hi,
In the end Alfresco recommends to use sub-components indeed, as Axel also mentioned. A proper way to hide tag-filter on sidebar of document library is to create a Share module extension with following code:
<blockcode>
<module>
<id>Remove Tag filter</id>
<version>1.0</version>
<components>
<component>
<region-id>tags</region-id>
<source-id>documentlibrary</source-id>
<scope>template</scope>
<sub-components>
<sub-component id="default">
<evaluations>
<evaluation id="guaranteedToHide">
<render>false</render>
</evaluation>
</evaluations>
</sub-component>
</sub-components>
</component>
</components>
</module>
</blockcode>
In the end Alfresco recommends to use sub-components indeed, as Axel also mentioned. A proper way to hide tag-filter on sidebar of document library is to create a Share module extension with following code:
<blockcode>
<module>
<id>Remove Tag filter</id>
<version>1.0</version>
<components>
<component>
<region-id>tags</region-id>
<source-id>documentlibrary</source-id>
<scope>template</scope>
<sub-components>
<sub-component id="default">
<evaluations>
<evaluation id="guaranteedToHide">
<render>false</render>
</evaluation>
</evaluations>
</sub-component>
</sub-components>
</component>
</components>
</module>
</blockcode>
