+

Search Tips   |   Advanced Search

Create resources

We create resources using methods of controllers. Each controller type enables the specific resources for its type of model.

  • ContentModelController

    Enable the creation of resources...

    • ContentPage and ContentLabel

    • Types of content URL:

      • ExternalContentURL
      • InternalContentURL

  • LayoutModelController

    Enable the creation of resources...

    • LayoutContainer
    • LayoutControl

  • PortletModelController

    Enable the creation of resources...

To create a resource...

  1. Obtain a creation context.

    1. Obtain the creation context builder factory.
    2. Obtain a creation context from the creation context builder.

  2. Obtain a controller.

  3. Create a resource.

    Use the create(Class, CreationContext) method of the controller and provide both arguments.


Results

  1. The created resource is not part of the topology, unless you insert it into the topology using the insert() method of the controller.

  2. For content nodes (pages, labels, and URLs), set a supported markup. Otherwise, they do not show in the read-only model.


Example

Create a resource using the creation context builder. This example creates a ContentPage we can later insert into the content model.

final CreationContextBuilderFactory builder = CreationContextBuilderFactory.getInstance();


 // obtain creation context 
final CreationContext creationContext = builder.newIdentifiableCreationContext(objectID);

 // create resource (Not yet part of the topology of the controller!)
final Modifiable modifiable = controller.create(ContentPage.class, creationContext)
;

Clone an existing portlet definition. To clone an existing portlet definition, create a portlet definition using a portlet model controller and specify a PortletDefinitionCloningContext.

// Obtain portlet definition cloning context. Includes obtaining a portlet definition 

final PortletDefinitionCloningContext context = ...  (portletDefinition)

 // create portlet definition 
pmController.create(PortletDefinition.class, context);

The result of the create() method is a Modifiable instance of the created resource we can cast to the type of the created resource as shown in the following example.

Caste a created resource to its type:

final ModifiableContentPage modifiableContentPage = (ModifiableContentPage) controller.create(ContentPage.class, creationContext); 


See


Parent Modify portal resources and topologies