Support and Documentation

Lesson 5: Referenced content

A large part of content modeling in Brightspot involves assembling parent content types out of lower-level content types. In this lesson you will create a child content type for authors, and then include that content type inside the parent article content type you made in the previous lessons. You will also observe how Brightspot manages the interaction between parent and content types in the content edit form.

Step 1: Prepare for this lesson

Before starting this lesson, do the following:

  1. Complete Lesson 1: Create an Article content type.

  2. If you stopped the Brightspot server, do the following:

    1. Restart it by typing ./ (Linux, OS X) or run.cmd (Windows). The login page appears in your browser at localhost:9480.

    2. Log in to display the dashboard.

Step 2: Declare the Author class

In this step you declare a Java class for the author content type.

  1. Change to the source-file directory brightspot-tutorial/init/src/main/java/.

  2. Create the directory author, and change to that directory (see the illustration Tutorial project structure).

  3. Create the file, and enter the following text:

    package author;
    import com.psddev.cms.db.Content;
    public class Author extends Content  {
        private String lastName;
        private String firstName;

The previous snippet is a model representing authors. Each author has a last name and a first name.

Step 3: Create an author
  1. Refresh the content edit form.

  2. In the header, click in the search field. The search panel appears.

  3. In the Create widget, select Author.

  4. Click New. A content edit page appears for adding an author.

  5. Enter a last name and a first name, and then click Publish.

  6. Click |mi-settings|, and from the menu select New Author.

  7. Repeat steps 5–6 to add a few more authors.

Step 4: Include the author in the article content type
  1. Update the file (see the illustration Tutorial project structure) as follows:

    package article;
    import com.psddev.cms.db.Content;
    import com.psddev.cms.db.ToolUi;
    import com.psddev.dari.util.StorageItem;
    import com.psddev.dari.util.StringUtils;
    import com.psddev.cms.db.Directory;
    import com.psddev.cms.db.Site;
    import author.Author;
    public class Article extends Content  implements Directory.Item  {
        private String headline;
        private String body;
        private Author author;
        private StorageItem image;
        public String getHeadline() {
            return headline;
        public String getBody() {
            return body;
        public StorageItem getImage() {
            return image;
        public String createPermalink(Site site) {
            return StringUtils.toNormalized(getHeadline());
  2. Refresh the content edit form.

  3. Return to the dashboard, and from the Recent Activity widget, click the article you created in Lesson 1: Create an Article content type. Brightspot opens the article in the content edit page.

  4. Open the Author list. (If you do not see the Author list, halt the server in the terminal window by pressing Ctrl-C, restarting the server with ./ or run.cmd, and then reloading the page in the browser.) Brightspot lists the author you created in Step 3: Create an author.

  5. In the Author field, click search. A content picker appears.

  6. Click one of the available authors you created in Step 3: Create an author. You return to the content edit page with the selected author in the Author field.

  7. Click Publish.

When you open the Author list, or when you open the content picker from the Author list, Brightspot retrieves available objects of class Author. When you click Publish, Brightspot saves the article that now includes a pointer to the selected author. (You can also embed child content directly into parent content; see the annotation @Recordable.Embedded.)


In this lesson you learned the following:

  • How to add a child content type to a parent content type.

  • How Brightspot renders a content edit form that incorporates the child into the parent.

  • How Brightspot renders a content picker populated with objects of a particular content type.

  • Brightspot can store references to content types as pointers.