public static class RemoveChildActionListener extends EventListener<UIPage> {
public void execute(Event<UIPage> event) throws Exception {
UIPage uiPage = event.getSource();
String id = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
if (uiPage.isModifiable()) {
uiPage.removeChildById(id);
Page page = (Page) PortalDataMapper.buildModelObject(uiPage);
if (page.getChildren() == null) {
page.setChildren(new ArrayList<ModelObject>());
}
//
PageService pageService = uiPage.getApplicationComponent(PageService.class);
PageState pageState = new PageState(page.getTitle(), page.getDescription(), page.isShowMaxWindow(),
page.getFactoryId(), page.getAccessPermissions() != null ? Arrays.asList(page.getAccessPermissions())
: null, page.getEditPermission());
pageService.savePage(new PageContext(page.getPageKey(), pageState));
//
DataStorage dataService = uiPage.getApplicationComponent(DataStorage.class);
dataService.save(page);
//
pcontext.ignoreAJAXUpdateOnPortlets(false);
pcontext.setResponseComplete(true);
pcontext.getWriter().write(EventListener.RESULT_OK);
} else {
org.exoplatform.webui.core.UIApplication uiApp = pcontext.getUIApplication();
uiApp.addMessage(new ApplicationMessage("UIPage.msg.EditPermission.null", null));
}
}