+

Search Tips   |   Advanced Search

Set titles and descriptions


We can set the titles and descriptions of a resource.

To do this...

  1. Obtain a modifiable instance of the resource for which to set titles or descriptions.

  2. Check whether the resource implements the ModifiableLocalized interface. To do this, use the operator instanceof. If the resource does not implement the ModifiableLocalized interface, we cannot modify it.

  3. Use the appropriate methods to set titles and descriptions.

    For example, to set a title, use the setTitle method.

We cannot set a description in a particular locale without having a title set is that same locale.

Example - Modifying titles and descriptions:

// 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");
}


Parent: Modify properties
Related:
Set unique names
Set metadata
Set supported markups
Set the orientation for layout containers
Set portlet preferences
Set flags
Set themes
Set URLs