KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > user > component > UILanguageSelector


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.faces.user.component;
6
7 import java.util.Collection JavaDoc;
8 import javax.faces.component.UIComponent;
9 import org.exoplatform.container.SessionContainer;
10 import org.exoplatform.faces.core.component.UIExoCommand;
11 import org.exoplatform.faces.core.component.model.Parameter;
12 import org.exoplatform.faces.core.event.ExoActionEvent;
13 import org.exoplatform.faces.core.event.ExoActionListener;
14 import org.exoplatform.portal.PortalConstants;
15 import org.exoplatform.portal.session.ExoPortal;
16 import org.exoplatform.services.resources.LocaleConfigService;
17
18 /**
19  * Sat, Jan 03, 2004 @ 11:16
20  * @author: Tuan Nguyen
21  * @email: tuan08@users.sourceforge.net
22  * @version: $Id: UIUserInfo.java,v 1.10 2004/07/02 20:48:33 tuan08 Exp $
23  */

24 public class UILanguageSelector extends UIExoCommand {
25   public static final String JavaDoc COMPONENT_FAMILY = "org.exoplatform.faces.user.component.UILanguageSelector" ;
26   public static final String JavaDoc CHANGE_ACTION = "change";
27   public static final String JavaDoc LOCALE_NAME = "localeName";
28   public static final Parameter CHANGE_PARAM = new Parameter(ACTION, CHANGE_ACTION) ;
29
30   private Collection JavaDoc configs_ ;
31   
32   public UILanguageSelector(LocaleConfigService manager) throws Exception JavaDoc {
33     setId("UILanguageSelector") ;
34     setRendererType("LanguageSelectorRenderer") ;
35     configs_ = manager.getLocalConfigs() ;
36     addActionListener(ChangeLocaleActionListener.class, CHANGE_ACTION) ;
37   }
38   
39   public Collection JavaDoc getLocaleConfigs() { return configs_ ; }
40   
41   public String JavaDoc getFamily() { return COMPONENT_FAMILY ; }
42   
43   static public class ChangeLocaleActionListener extends ExoActionListener {
44     public void execute(ExoActionEvent event) throws Exception JavaDoc {
45       String JavaDoc localeName = event.getParameter(LOCALE_NAME) ;
46       UIComponent portal = (UIComponent) SessionContainer.getComponent(ExoPortal.class) ;
47       ExoActionEvent portalEvent =
48         new ExoActionEvent(portal, PortalConstants.CHANGE_LANGUAGE_ACTION) ;
49       portalEvent.addParameter(PortalConstants.LANGUAGE_PARAM, localeName) ;
50       portal.queueEvent(portalEvent) ;
51     }
52   }
53 }
Popular Tags