Setting titles and descriptions
You can set the titles and descriptions of a resource.
About this task
To do this, proceed by the following steps:
Procedure
- Obtain a modifiable instance of the resource for which you want to set titles or descriptions.
- Check whether the resource implements the ModifiableLocalized interface. To do this, use the operator instanceof. If the resource does not implement the ModifiableLocalized interface, you cannot modify it.
- Use the appropriate methods to set titles and descriptions. For example, if you want to set a title, use the setTitle method.
Results
Note: You cannot set a description in a particular locale without
having a title set in that same locale.
Example
// obtain modifiable instance of a model node
final Modifiable modifiable = controller.getModifiableNode(node);
// check if the resource implements ModifiableLocalized interface
if (modifiable instanceof ModifiableLocalized) {
// set title and description
((ModifiableLocalized) modifiable).setTitle(Locale.GERMAN, "Titel");
((ModifiableLocalized) modifiable).setDescription(Locale.GERMAN, "Beschreibung");
}