UIPageNodeSelector uiNodeSelector = uiPageInfo.getChild(UIPageNodeSelector.class);
PageNavigation pageNavi = uiNodeSelector.getSelectedNavigation();
String ownerType = pageNavi.getOwnerType();
String ownerId = pageNavi.getOwnerId();
PageNode pageNode = uiPageInfo.getPageNode();
Page page = uiPageTemplateOptions.createPageFromSelectedOption(ownerType, ownerId);
page.setName("page" + page.hashCode());
String pageId = pageNavi.getOwnerType() + "::" + pageNavi.getOwnerId() + "::" + page.getName();
DataStorage storage = uiWizard.getApplicationComponent(DataStorage.class);
if (storage.getPage(pageId) != null)
{
uiPortalApp.addMessage(new ApplicationMessage("UIPageCreationWizard.msg.NameNotSame", null));
uiWizard.viewStep(FIRST_STEP);
uiWizard.updateWizardComponent();
}
page.setModifiable(true);
// Set default permissions on the page
setDefaultPermission(page, ownerType, ownerId);
if (page.getTitle() == null || page.getTitle().trim().length() == 0)
{
page.setTitle(pageNode.getName());
}
boolean isDesktopPage = Page.DESKTOP_PAGE.equals(page.getFactoryId());
if (isDesktopPage)
{
page.setShowMaxWindow(true);
}
UIPagePreview uiPagePreview = uiWizard.getChild(UIPagePreview.class);
UIPage uiPage;
if (Page.DESKTOP_PAGE.equals(page.getFactoryId()))
{
uiPage = uiWizard.createUIComponent(context, UIDesktopPage.class, null, null);
}
else
{
uiPage = uiWizard.createUIComponent(context, UIPage.class, null, null);
}
PortalDataMapper.toUIPage(uiPage, page);
uiPagePreview.setUIComponent(uiPage);
if (isDesktopPage)
{
uiWizard.saveData();
PageNode selectedNode = uiNodeSelector.getSelectedPageNode();
UIPortal uiPortal = Util.getUIPortal();
PageNodeEvent<UIPortal> pnevent = new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE, selectedNode.getUri());
uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
uiWizard.updateUIPortal(event);
return;
}