Search in sources :

Example 1 with PageRegions

use of com.enonic.xp.page.PageRegions in project xp by enonic.

the class MappingHandlerTest method createPage.

private Content createPage(final String id, final String path, final String contentTypeName, final boolean withPage) {
    PropertyTree rootDataSet = new PropertyTree();
    rootDataSet.addString("property1", "value1");
    final Content.Builder content = Content.create().id(ContentId.from(id)).path(ContentPath.from(path)).owner(PrincipalKey.from("user:myStore:me")).displayName("My Content").modifier(PrincipalKey.from("user:system:admin")).type(ContentTypeName.from(contentTypeName));
    if (withPage) {
        PageRegions pageRegions = PageRegions.create().add(Region.create().name("main-region").add(PartComponent.create().descriptor("myapp:mypart").build()).build()).build();
        Page page = Page.create().template(PageTemplateKey.from("my-page")).regions(pageRegions).config(rootDataSet).build();
        content.page(page);
    }
    return content.build();
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Page(com.enonic.xp.page.Page)

Example 2 with PageRegions

use of com.enonic.xp.page.PageRegions in project xp by enonic.

the class RenderBaseHandlerTest method createPage.

private Content createPage(final String id, final String path, final String contentTypeName, final boolean withPage) {
    PropertyTree rootDataSet = new PropertyTree();
    rootDataSet.addString("property1", "value1");
    final Content.Builder content = Content.create().id(ContentId.from(id)).path(ContentPath.from(path)).owner(PrincipalKey.from("user:myStore:me")).displayName("My Content").modifier(PrincipalKey.from("user:system:admin")).type(ContentTypeName.from(contentTypeName));
    if (withPage) {
        PageRegions pageRegions = PageRegions.create().add(Region.create().name("main-region").add(PartComponent.create().descriptor("myapp:mypart").build()).build()).build();
        Page page = Page.create().template(PageTemplateKey.from("my-page")).regions(pageRegions).config(rootDataSet).build();
        content.page(page);
    }
    return content.build();
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Page(com.enonic.xp.page.Page)

Example 3 with PageRegions

use of com.enonic.xp.page.PageRegions in project xp by enonic.

the class ProjectContentEventListenerTest method createPage.

private Page createPage() {
    PropertyTree componentConfig = new PropertyTree();
    componentConfig.setString("my-prop", "value");
    PartComponent component = PartComponent.create().descriptor(DescriptorKey.from("mainapplication:partTemplateName")).config(componentConfig).build();
    Region region = Region.create().name("my-region").add(component).build();
    PageRegions regions = PageRegions.create().add(region).build();
    PropertyTree pageConfig = new PropertyTree();
    pageConfig.setString("background-color", "blue");
    Mockito.when(partDescriptorService.getByKey(DescriptorKey.from("mainapplication:partTemplateName"))).thenReturn(PartDescriptor.create().key(DescriptorKey.from("mainapplication:partTemplateName")).displayName("my-component").config(Form.create().build()).build());
    return Page.create().template(PageTemplateKey.from("mypagetemplate")).regions(regions).build();
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) PropertyTree(com.enonic.xp.data.PropertyTree) Region(com.enonic.xp.region.Region) PartComponent(com.enonic.xp.region.PartComponent)

Example 4 with PageRegions

use of com.enonic.xp.page.PageRegions in project xp by enonic.

the class ComponentInstruction method resolveComponent.

private Component resolveComponent(final PortalRequest portalRequest, final ComponentPath path) {
    final Content content = portalRequest.getContent();
    if (content == null) {
        return null;
    }
    final Page page = content.getPage();
    if (content.getType().isFragment()) {
        return resolveComponentInFragment(page, path);
    }
    final PageRegions pageRegions = page.getRegions();
    Component component = pageRegions.getComponent(path);
    if (component == null) {
        throw new RenderException("Component not found: [{0}]", path);
    }
    return component;
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) RenderException(com.enonic.xp.portal.impl.rendering.RenderException) Content(com.enonic.xp.content.Content) Page(com.enonic.xp.page.Page) LayoutComponent(com.enonic.xp.region.LayoutComponent) Component(com.enonic.xp.region.Component)

Example 5 with PageRegions

use of com.enonic.xp.page.PageRegions in project xp by enonic.

the class ServiceHandlerTest method createPage.

private Content createPage(final String id, final String path, final String contentTypeName, final boolean withPage) {
    PropertyTree rootDataSet = new PropertyTree();
    rootDataSet.addString("property1", "value1");
    final Content.Builder content = Content.create().id(ContentId.from(id)).path(ContentPath.from(path)).owner(PrincipalKey.from("user:myStore:me")).displayName("My Content").modifier(PrincipalKey.from("user:system:admin")).type(ContentTypeName.from(contentTypeName));
    if (withPage) {
        PageRegions pageRegions = PageRegions.create().add(Region.create().name("main-region").add(PartComponent.create().descriptor("myapp:mypart").build()).build()).build();
        Page page = Page.create().template(PageTemplateKey.from("my-page")).regions(pageRegions).config(rootDataSet).build();
        content.page(page);
    }
    return content.build();
}
Also used : PageRegions(com.enonic.xp.page.PageRegions) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) Page(com.enonic.xp.page.Page)

Aggregations

PageRegions (com.enonic.xp.page.PageRegions)17 PropertyTree (com.enonic.xp.data.PropertyTree)9 Page (com.enonic.xp.page.Page)8 Content (com.enonic.xp.content.Content)6 Test (org.junit.jupiter.api.Test)6 Region (com.enonic.xp.region.Region)3 DescriptorKey (com.enonic.xp.page.DescriptorKey)1 PageDescriptor (com.enonic.xp.page.PageDescriptor)1 PageTemplate (com.enonic.xp.page.PageTemplate)1 RenderException (com.enonic.xp.portal.impl.rendering.RenderException)1 Component (com.enonic.xp.region.Component)1 LayoutComponent (com.enonic.xp.region.LayoutComponent)1 PartComponent (com.enonic.xp.region.PartComponent)1 RegionDescriptors (com.enonic.xp.region.RegionDescriptors)1