10.5.3. Page

Warning

You are looking at documentation for an older release. Not what you want? See the current release documentation.

Portal Page aggregates content from one or more Portlets.

Retrieving Pages

A specific page can be retrieved by its PageId. The PageId is constructed by passing either the name for a standard site, the group for a group space or the user for a user dashboard, and the name of the page. Alternatively it can be constructed by passing the SiteId and name of the page.

Example of retrieving specific pages is shown below:



Page standardSitePage = portal.getPage("classic", "home");
Page groupSpacePage = portal.getSite(new Group("platform", "administrators"), "grouppage");
Page userDashboardPage = portal.getSite(new User("john", "johnspage"));

It is also possible to query for pages using the PageQuery. The PageQuery supports filtering, sorting and pagination when querying for pages.

The example below finds pages with a display name that starts with "A":



PageQuery.Builder qb = new PageQuery.Builder();
 
qb.withSiteType(SiteType.SITE).withFilter(new Filter<Page>() {
    public boolean accept(Page page) {
        return page.getDisplayName().startsWith("A");
    }
});
 
List<Page> pages = portal.findPages(qb.build());

Creating a Page

To create a page, first create a new page through the Portal, then set the configuration for the page (such as localized display names), and finally saved it using the Portal.

The example below creates a new page in the classic site with the name mypage and a non-localized display name:



Page page = portal.createPage(new PageId("classic", "mypage"));
page.setDisplayName("My Page");
portal.savePage(page);

Note

The changed permissions do not take affect until savePage is invoked.

Setting Permissions for a Page

Associated with a page is an access permission and an edit permission, which controls what users and groups are allowed to access and edit the page respectively.

The example below makes a page accessible to everyone, but only editable by users in the /platform/administrators group:



page.setAccessPermission(Permission.everyone());
page.setEditPermission(Permission.any("platform", "administrators"));
 
portal.savePage(page);

Note

The changed permissions do not take affect until savePage is invoked.

Deleting a Page

A page is deleted by invoking removePage on the Portal.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus