Creating A Decorator

A CUE content item decorator is a Java class that:

  • Extends neo.xredsys.presentation.PresentationArticleDecorator

  • Contains a get method for each content item property it is to modify

The following example shows a content item decorator that converts a content item's title property to upper case:

package com.mycompany.decorators;

import neo.xredsys.presentation.*;

public class TitleToUpperCase extends PresentationArticleDecorator {
  public TitleToUpperCase(PresentationArticle pa) {

  public String getTitle() {
    String title = super.getTitle().toUpperCase();
    return title;

The PresentationArticleDecorator class implements the PresentationArticle interface. Since the TitleToUpperCase class extends PresentationArticleDecorator, it can be used to override methods in the standard implementation of PresentationArticle. In this case, the getTitle() method will override the standard PresentationArticle.getTitle() method.

The TitleToUpperCase constructor accepts a PresentationArticle bean as input parameter and stores it in the property super (i.e, superclass). When a bean for a content type that is configured to use the TitleToUpperCase decorator is created, the Content Store:

  • Creates a standard PresentationArticle bean

  • Creates a TitleToUpperCase bean, passing in the PresentationArticle bean as its constructor parameter

When the article's getTitle() method is called, TitleToUpperCase.getTitle():

  1. Calls super's getTitle() method to get the title property

  2. Calls String.toUpperCase() to convert the title to upper case

  3. Returns the result

Note the following points:

  • A decorator changes the behavior of the content item bean itself. It does not matter whether you access the title property via a JSP tag or in-line java - it will always be returned in upper case.

  • Only the specified property is affected. If you access the title field directly via the Java getFieldElement() method, then it will not be converted to upper case.

Before a decorator can be used it must be:

  • Compiled

  • Added to the web application's classpath

To compile a decorator you need the following CUE JAR files in your classpath:

  • engine-core-7.0.2-2.jar

  • engine-presentation-7.0.2-2.jar

  • common-util-n.n.n.n.jar (replace n.n.n.n with the version number of the common-util library included with the current version of the Content Store).