1 5 package org.exoplatform.portal.faces.listener.portal; 6 7 import org.exoplatform.container.PortalContainer; 8 import org.exoplatform.faces.core.event.ExoActionEvent; 9 import org.exoplatform.faces.core.event.ExoActionListener; 10 import org.exoplatform.portal.PortalConstants; 11 import org.exoplatform.portal.faces.component.*; 12 import org.exoplatform.services.portal.PortalConfigService; 13 import org.exoplatform.services.portal.model.PortalConfig; 14 19 public class PortalActionListener extends ExoActionListener { 20 public void execute(ExoActionEvent event) throws Exception { 21 UIPortal uiPortal = (UIPortal) event.getSource() ; 22 String portalAction = event.getAction() ; 23 if (PortalConstants.SAVE_PORTAL_ACTION.equals(portalAction)) { 24 if(!uiPortal.isDirty()) return ; 25 PortalConfigService service = 26 (PortalConfigService)PortalContainer.getInstance(). 27 getComponentInstanceOfType(PortalConfigService.class) ; 28 UIContainer uiLayout = (UIContainer) uiPortal.getChildren().get(0) ; 29 uiLayout.buildTreeModel(null) ; 30 PortalConfig componentModel = uiPortal.getPortalConfigModel() ; 31 componentModel.setLayout(uiLayout.getContainerModel()) ; 32 service.savePortalConfig(componentModel) ; 33 uiPortal.setComponentDirty(false) ; 34 uiPortal.clearComponentModified() ; 35 } else if (PortalConstants.EDIT_PORTAL_ACTION.equals(portalAction)) { 36 UIPortalForm uiPortalForm = 37 (UIPortalForm)uiPortal.getPortalComponent(UIPortalForm.class) ; 38 uiPortalForm.setUIPortal(uiPortal); 39 uiPortal.setBodyComponent(uiPortalForm) ; 40 } else if (PortalConstants.CHANGE_LANGUAGE_ACTION.equals(portalAction)) { 41 String localeName = event.getParameter(PortalConstants.LANGUAGE_PARAM) ; 42 new ChangeLocaleVisitor().changeLocale(uiPortal, localeName) ; 43 new ChangeLocaleVisitor().changeLocale(uiPortal.getCurrentUIPage()) ; 44 } 45 } 46 } | Popular Tags |