Chapter 6. Page

6.1. 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 6.1. Retrieving Specific Pages

This example shows how to retrieve specific pages of a portal.
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.

Example 6.2. Retrieve Pages Using Filtering, Sorting, and Pagination

This example 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());

6.2. Creating a Page

Creating a page uses the following workflow:
  1. Create a new page through the Portal.
  2. Set the configuration for the page (such as localized display names).
  3. Save it using Portal.

Example 6.3. Create a Page

This example creates a new page in the classic site with the name mypage and a non-localized display name.
The page is not visible (or persisted) until portal.savePage is invoked.

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

6.2.1. 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.

Example 6.4. Set Permissions for a Page

This example makes a page accessible to everyone, but only editable by users in the /platform/administrators group.
The changed permissions do not take affect until savePage is invoked.

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

portal.savePage(page);

6.3. Deleting a Page

A page is deleted by invoking removePage on the Portal.