Overwritten template has no effect Overwritten template has no effect

Today we have a question from Simon who asks why his custom template doesn't override the default one. While he does have his template at the right place in his bundle and his deployment-fragment written to extract the template at the right place, it still doesn't work. In the end he still has the default file.

What happened is that is file has been extracted at the right place but before the default one. So his own template has been overridden by the default one. To avoid this issue, you need to add a require tag on your deployment-fragment. As Anahide said in her comment, we need the following:

[xml]
<require>org.nuxeo.ecm.webapp.base</require>
[/xml]

But why is it org.nuxeo.ecm.webapp.base? This is actually the Bundle-SymbolicName in the MANIFEST.MF of the bundle you want to override.

So every time you're doing something in the deployment-fragment that needs a bundle to be deployed before, you need that require tag. You can checkout another example on a previous blog about nuxeo-platform-lang and nuxeo-platform-lang-ext.

But there are many other time when you need a require tag. It doesn't apply only to deployment-fragment. In fact it applies to every XML component. Lets say for a moment that you don't really like the Alert tab label. You would like to call it Notifications instead. So you would need to contribute to the action extension point. The first step is to identify the id of the action you want to override. You can browse the sources with Nuxeo IDE or go directly in Nuxeo Explorer where you can see the list of contributions to the action extension point. There is one called org.nuxeo.ecm.platform.notifications.web.actions--actions. That's exactly the one we need. The first information you have on this page is In component org.nuxeo.ecm.platform.notifications.web.actions . It's the name of the component containing the contribution we were looking for:

[xml]
<extension point="actions" target="org.nuxeo.ecm.platform.actions.ActionService">

&lt;documentation&gt;
  Contribute a new tab where a user can subscribe to notifications.
&lt;/documentation&gt;

&lt;action enabled=&quot;true&quot; icon=&quot;/icons/file.gif&quot; id=&quot;TAB_MY_SUBSCRIPTIONS&quot; label=&quot;action.subscriptions.tab&quot; link=&quot;/incl/tabs/document_subscriptions.xhtml&quot; order=&quot;70&quot;&gt;
  &lt;category&gt;VIEW_ACTION_LIST&lt;/category&gt;
  &lt;filter-id&gt;general_documents&lt;/filter-id&gt;
  &lt;filter-id&gt;not_anonymous&lt;/filter-id&gt;
&lt;/action&gt;

&lt;action enabled=&quot;true&quot; icon=&quot;/icons/file.gif&quot; id=&quot;TAB_MANAGE_SUBSCRIPTIONS&quot; label=&quot;action.groups.subscriptions.tab&quot; link=&quot;/incl/tabs/document_group_subscriptions.xhtml&quot; order=&quot;80&quot;&gt;
  &lt;category&gt;TAB_MANAGE_sub_tab&lt;/category&gt;
  &lt;filter-id&gt;general_documents&lt;/filter-id&gt;
  &lt;filter-id&gt;manage_subscriptions&lt;/filter-id&gt;
&lt;/action&gt;

&lt;action enabled=&quot;false&quot; id=&quot;sendEmail&quot;/&gt;

&lt;action enabled=&quot;true&quot; icon=&quot;/icons/mail.gif&quot; id=&quot;sendNotificationEmail&quot; label=&quot;action.email.document&quot; link=&quot;send_notification_email&quot; order=&quot;17&quot;&gt;
  &lt;category&gt;DOCUMENT_UPPER_ACTION&lt;/category&gt;
  &lt;filter-id&gt;not_folder&lt;/filter-id&gt;
  &lt;filter-id&gt;not_anonymous&lt;/filter-id&gt;
&lt;/action&gt;

</extension>
[/xml]

The action defining the Alert tab is the first one with the TAB_MY_SUBSCRIPTIONS id. If you want to make sure it's the right one, take a look the URL of a page displaying the alert tab:
https://yourserver.com/nuxeo/nxpath/default/default-domain/workspaces/[email protected]_documents?tabIds=%3ATAB_MY_SUBSCRIPTIONS&conversationId=0NXMAIN
You can see the id in the tabIds query parameter: tabIds=%3ATAB_MY_SUBSCRIPTIONS

Now that we're sure we found the contribution we want to override, let's get to it:

[xml]
<?xml version="1.0"?>
<component name="org.nuxeo.sample.action.contrib.override">
<!-- Component name must be unique. -->
<!-- The require tag contains the name of the component
holding the contribution we want to override. -->
<require>org.nuxeo.ecm.platform.notifications.web.actions</require>

<extension point="actions" target="org.nuxeo.ecm.platform.actions.ActionService">

&lt;documentation&gt;
  Override the TAB_MY_SUBSCRIPTIONS action to change its label.
&lt;/documentation&gt;

&lt;action id=&quot;TAB_MY_SUBSCRIPTIONS&quot; label=&quot;my.new.label&quot; /&gt;

</extension>

</component>
[/xml]

As you can see we only have to provide the action id and the new label. This is because the service managing this extension point knows how to merge the action contribution. Some services only overwrite the contribution. T‎his really depends on how it was written so make sure you check out their documentation if you need to overrride a contribution.

So here's a small recap:


  • If you need to override something in a deployment-fragment, the require tag must contains the Bundle-SymbolicName in the MANIFEST.MF of the bundle containing the deployment-fragment you want to override.

  • If you need to override an extension point contribution, the require tag must contain the name of the component you want to be deployed after.


That's it for today, See ya on Monday!