KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portal > faces > listener > portal > PortalActionListener


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

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 /**
15  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
16  * @since Aug 16, 2004
17  * @version $Id: PortalActionListener.java,v 1.3 2004/09/27 20:44:59 tuan08 Exp $
18  */

19 public class PortalActionListener extends ExoActionListener {
20   public void execute(ExoActionEvent event) throws Exception JavaDoc {
21     UIPortal uiPortal = (UIPortal) event.getSource() ;
22     String JavaDoc 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 JavaDoc localeName = event.getParameter(PortalConstants.LANGUAGE_PARAM) ;
42       new ChangeLocaleVisitor().changeLocale(uiPortal, localeName) ;
43       new ChangeLocaleVisitor().changeLocale(uiPortal.getCurrentUIPage()) ;
44     }
45   }
46 }
Popular Tags