Brightspot CMS Developer Guide

Inheritance


Inheritance of classes works in Brightspot as expected in Java. Brightspot does not save instances of abstract classes, such as BaseArticle:

public abstract class BaseArticle extends Content {

    private String headline;

    private Author author;

    @ToolUi.RichText
    private bodyText;

}

Concrete classes extending an abstract class are available in Brightspot. For example, users can create new instances of the following NewsArticle concrete class.

Subclassed content type

public class NewsArticle extends BaseArticle {

    private List<String> newsKeywords;

}

The Brightspot UI reflects both the base fields and fields derived from parent classes, and allows you to search any of those fields.

Inheritance.png

The Dari framework provides functionality to assist you in working with inheritance relationships:

  • The Database Schema Viewer shows class relationships in the data model.
  • See FROM for information about searching on abstract classes. To use the above example, you could search on BaseArticle, and the Query API would return all instances that inherit from that base class.

Modifications provide the capability to add new fields to existing classes. They can be used to update classes for which you do not have the source. In addition, modifications can be the best solution for adding new fields to many classes, a solution that leverages Java inheritance.

For example, say that you want to add a logo and release date to all of the Content-derived classes on a site. You can add the logo field to each base class that derives from Content. Alternatively, you can create a Logo class that extends the Modification class. The target of the modification is Content, so the modification impacts all new and existing objects that inherit from Content.

public class Logo extends Modification<Content> {

   private StorageItem logoImage;

   private Date releaseDate;

}

In the previous snippet, the class extends Modification<content>, which means all classes extending from Content inherit the new fields logoImage and releaseDate. At run time, for example, Brightspot renders the form for the class NewsArticle in listing "Subclassed content type" as follows:

InhertianceModifications.png

See Modifications for more information.

Previous Topic
Image modeling
Next Topic
Resource bundles
Was this topic helpful?
Thanks for your feedback.
The elements that get you up and running in a matter of days, from pre-built content types, to modules, to landing pages.

Content types
Modules
Landing pages
Everything you need to manage and administer content within Brightspot CMS, including plug-and-play integrations.

Dashboards
Authoring content
Workflows
Admin configurations
A guide for installing, supporting and administering code on the Brightspot platform, including integrations requiring developer support to use.

Field types
Content modeling
Rich-text elements
Images