Resource Bundles

You can use Java-style .properties files to customize the content edit form for a given Model.

Note

Resource bundles are also used for localization. For details, see Localization.

Creating Properties Files

The following procedure describes how to create a properties file for a given Model.

  1. Change to or create the resources/ directory for your Brightspot project. This directory is in the standard position for Maven projects, src/main/resources/, although your Brightspot project may have a different resources/ directory for different themes.
  2. Change to or create the subdirectory corresponding to the required Model. For example, if you are configuring the content edit form for a Model brightspot/core/article/Article.java, change to or create the resources subdirectory brightspot/core/article/.
  3. Create or open the file <ContentType>Default_xx.properties, where xx is the code of the target language. For example, the file ArticleDefault_en.properties overrides the Model associated with articles for English-language locales. For a list of two-letter language codes, see Codes for the Representation of Names of Languages.
  4. In the properties file, add lines of the form key=value. Use the following sections for a description of the available keys.
  5. Reload or rebuild your Brightspot project.

Renaming Fields

The properties key field renames a field on the content edit form.

  1. Following the procedure in Creating Properties Files, create or open open the appropriate .properties file.
  2. In the properties file, add a line of the form field.<fieldname>=<newname>.

Fields not appearing in this file have labels derived from their names in the Model or as otherwise annotated.

The following snippet renames the field headline on the content edit form.

field.headline=Teaser Headline
../../../_images/field-label.png

For additional information, see @Recordable.DisplayName.

Renaming Tabs

Brightspot provides default tabs that it displays on content edit forms, such as Main and SEO. You can rename these tabs using the properties key tab. Custom tabs defined in a Model via @ToolUi.Tab can also be renamed in the properties file.

  1. Following the procedure in Creating Properties Files, create or open open the appropriate .properties file.
  2. In the properties file, add a line of the form tab.<tabname>=<newname>.

The following snippet renames the tab Main on the content edit form.

tab.Main=Content
../../../_images/tab-label.png

Renaming Content Types

The properties key displayName renames a content type throughout the Brightspot UI.

  1. Following the procedure in Creating Properties Files, create or open open the appropriate .properties file.
  2. In the properties file, add a line of the form displayName=NewLabel. Do not enclose the label in quotes.

In the file resources/article/ArticleOverride.properties, the following line displays Story instead of Article in Brightspot.

displayName=Story
../../../_images/file-properties-display-name.png

For additional information, see @Recordable.DisplayName.

Restricting Fields

The properties key field.<fieldName>.groups specifies the following:

The following conditions are required to use this property:

  • The property’s key <fieldname> must be of type Record (or one of its subclasses).
  • The content types listed in the property’s value are subclasses of the key’s content type.
  1. Following the procedure in Creating Properties Files, create or open open the appropriate .properties file.
  2. In the properties file, add a line of the form field.<fieldName>.groups=className[,className ...]. Ensure the class name is fully qualified.

The following snippets describe how to use this property.

Step 1: Create Model

Model for Restricting Fields
1
2
3
4
5
6
7
package brightspot.core.article;

public class Article extends Content {

    private Media media;

}

In the previous snippet, line 5 declares a field media of type Media (which itself is a subclass of Record).

Step 2: Create Subclasses

package brightspot.core.article;

public class HiResImage extends Media {

}

package brightspot.core.article;

public class LowResImage extends Media {

}

In the previous snippet, the classes HiResImage and LowResImage are subclasses of the content type Media in the snippet Model for Restricting Fields.

Step 3: Create Property File

field.media.groups=brightspot.core.article.HiResImage,brightspot.core.article.LowResImage

In the previous snippet, the property field.media.groups limits the selection field and the content picker to types of HiResImage and LowResImage—as well as to type Media.

Effect of Groups Key on Selection Field and Content Picker
../../../_images/groups-selection-fields.png ../../../_images/groups-content-picker.png

Hiding Content Types

The properties key hidden prevents a content type from appearing in Brightspot.

  1. Following the procedure in Creating Properties Files, create or open open the appropriate .properties file.
  2. In the properties file, add a line hidden=true.

In the file resources/article/ArticleOverride.properties, the following line prevents Article from appearing in Brightspot.

hidden=true

For additional information, see @ToolUi.Hidden.

Hiding Fields

The properties key field.<fieldName>.hidden hides <fieldName> in the content edit form.

  1. Following the procedure in Creating Properties Files, create or open open the appropriate .properties file.
  2. In the properties file, add a line of the form field.<fieldName>.hidden=true.

The following snippet hides the Sub Headline field in the content edit form.

field.subHeadline.hidden=true
../../../_images/subheadline-visible.png ../../../_images/subheadline-hidden.png
Content edit form with visible sub-headline. Content edit form with hidden sub-headline.

For additional information, see @ToolUi.Hidden.

Changing Field Order

The properties key fieldDisplayOrder sets the display order of fields on the content edit form.

  1. Following the procedure in Creating Properties Files, create or open open the appropriate .properties file.
  2. In the properties file, add a line of the form fieldDisplayOrder=fieldName [,fieldname ...].

Fields not appearing in this line appear in the order as in the Model or as otherwise annotated.

The following snippet places the author field before the headline and body fields in the content edit form.

fieldDisplayOrder=author,headline,body
../../../_images/field-display-order.png

For additional information, see @ToolUi.FieldDisplayOrder.

See also: