Support and Documentation

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

Example 23. Model for restricting fields
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.

Table 24. Effect of groups key on selection field and content picker
groups-selection-fields.svg
groups-content-picker.svg