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();
}
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();
}
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();
}
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;
}
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();
}
Aggregations