Using A Decorator

Once you have created a decorator class, all you need to do to use it is add it to a content type definition in the content-type resource using the decorator element. For example:

<content-type name="xyz">
  ...
  <ui:decorator class="com.mycompany.decorator.TitleToUpperCase"/>
  ...
</content-type>

Once you have done this, the decorator will automatically take effect for all content items of that type. You can add the decorator to as many content type definitions as you want.

You can add more than one decorator to a content type. For example:

<content-type name="xyz">
  ...
  <ui:decorator class="com.mycompany.decorator.TitleToUpperCase" />
  <ui:decorator class="com.mycompany.decorator.TitleTrim" />
  ...
</content-type>

Note the following:

  • The decorator element belongs to the interface-hints namespace, which means that its name will usually be preceded by a prefix (ui in the examples above) declared at the start of the content-types resource file. For full descriptions of the content-type and decorator elements, see the Escenic Content Engine Resource Reference.

  • The decorator element has an optional name attribute that you can use for documentation purposes if you wish.

  • Multiple decorators are executed in the order they appear in the content type definition. This may sometimes be significant.