Setting unique names | HCL Digital Experience
You can set unique names for resources.
About this task
To set the unique name for a resource, proceed by the following steps:
Procedure
- Obtain a modifiable instance of the resource for which you want to set the unique name.
-
Check whether the resource implements the
ModifiableIdentifiable
interface.To do this, use the operatorinstanceof
. If the resource does not implement theModifiableIdentifiable
interface, you cannot modify it. -
Obtain a modifiable instance of the resource object ID, that is
ModifiableObjectID
. To do this, use thegetModifiableObjectID
. -
Set the unique name by using the
setUniqueName()
method of theModifiableObjectID
.
Example
// obtain modifiable instance of a model node
final Modifiable modifiable = controller.getModifiableNode(node);
// obtain modifiable instance of the resource's object id; note that modifiable
// instances of all model nodes implement the ModifiableIdentifiable interface
final ModifiableObjectID modifiableObjectID = ((ModifiableIdentifiable)
modifiable).getModifiableObjectID();
// set unique name
modifiableObjectID.setUniqueName("MyUniqueName");