{
UIPortalApplication uiPortalApp = Util.getUIPortalApplication();
UIPortal uiPortal = uiPortalApp.getShowedUIPortal();
UIEditInlineWorkspace editInlineWS = event.getSource().getParent();
UIWorkingWorkspace uiWorkingWS = editInlineWS.getParent();
UIPortalToolPanel uiToolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
UIPage uiPage = uiToolPanel.findFirstComponentOfType(UIPage.class);
Page page = (Page)PortalDataMapper.buildModelObject(uiPage);
String pageId = page.getPageId();
UserPortalConfigService portalConfigService =
uiWorkingWS.getApplicationComponent(UserPortalConfigService.class);
/*
* if it is a edition of the current page
*/
if (page.getStorageId() != null && portalConfigService.getPage(pageId) == null)
{
uiPortalApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.PageNotExist", new String[]{pageId}, 1));
uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
Util.getPortalRequestContext().setFullRender(true);
PageNodeEvent<UIPortal> pnevent =
new PageNodeEvent<UIPortal>(uiPortal, PageNodeEvent.CHANGE_PAGE_NODE,
(uiPortal.getSelectedNode() != null ? uiPortal.getSelectedNode().getUri() : null));
uiPortal.broadcast(pnevent, Event.Phase.PROCESS);
JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
jsManager.addJavascript("eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
return;
}
UIPortalComposer composer = uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class).setRendered(false);
composer.setEditted(false);
// If it is a page creation wizard
if (composer.isUsedInWizard())
{
UIWizard wizard = (UIWizard)uiToolPanel.getUIComponent();
int step = wizard.getCurrentStep();
step++;
Event<UIComponent> uiEvent =
wizard.createEvent("ViewStep" + step, Phase.PROCESS, event.getRequestContext());
uiEvent.broadcast();
return;
}
// Perform model update
DataStorage dataService = uiWorkingWS.getApplicationComponent(DataStorage.class);
try
{
dataService.save(page);
}
catch (StaleModelException ex)
{
//Temporary solution to concurrency-related issue
//This catch block should be put in an appropriate ApplicationLifecyclec
}
uiToolPanel.setUIComponent(null);
// Synchronize model object with UIPage object, that seems redundant but in fact
// mandatory to have consequent edit actions (on the same page) work properly
page = dataService.getPage(page.getPageId());
uiPage.getChildren().clear();