Last updated Apr 6, 2018

How do I associate my own properties with a ContentEntityObject?

To associate your own properties with a ContentEntityObject, you need the ContentPropertyManager (see how to retrieve it). This manager allows you to store and retrieve arbitrary string values associated with a ContentEntityObject.

Properties are stored as simple key/value pairs. We recommend that anyone writing a third-party plugin uses the standard Java "reverse domain name" syntax to ensure their keys are unique. Keys may be no longer than 200 characters.

1
2
// Set the property
contentPropertyManager.setText(page, "com.example.myProperty", "This is the value");
// Retrieve it
String myProperty = contentPropertyManager.getText(page, "com.example.myProperty");

getText and setText can store strings of arbitrary length (up to the size-limit for CLOBs in your database). There are also a getString and setString, which are slightly more efficient, but limited to 255 characters per value.

Rate this page: