·¬ÇÑÉçÇø

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 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 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 InhertianceModifications.png

See Modifications for more information.

Previous Topic
Image modeling
Next Topic
Resource bundles
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

•
•
•
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

• Content types
• Modules
• Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

• Dashboards
• Publishing
• Workflows
• Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

• Field types
• Content modeling
• Rich-text elements
• Images
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

• Google Analytics
• Shopify
• Apple News