KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > user > renderer > html > LanguageSelectorRenderer


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.renderer.html;
6
7 import java.util.ResourceBundle JavaDoc;
8 import java.io.IOException JavaDoc;
9 import java.util.Iterator JavaDoc ;
10 import javax.faces.component.UIComponent;
11 import javax.faces.context.FacesContext;
12 import javax.faces.context.ResponseWriter;
13 import org.exoplatform.faces.core.component.model.Parameter;
14 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer;
15 import org.exoplatform.faces.user.component.UILanguageSelector;
16 import org.exoplatform.services.resources.LocaleConfig;
17
18
19 /**
20  * @email: tuan08@users.sourceforge.net
21  * @version: $Id: UserInfoRenderer.java,v 1.15 2004/10/21 15:25:17 tuan08 Exp $
22  */

23 public class LanguageSelectorRenderer extends HtmlBasicRenderer {
24  
25   final public void encodeChildren( FacesContext context, UIComponent component ) throws IOException JavaDoc {
26     UILanguageSelector uiSelector = (UILanguageSelector) component ;
27     ResponseWriter w = context.getResponseWriter() ;
28     ResourceBundle JavaDoc res = getApplicationResourceBundle(context.getExternalContext()) ;
29     Parameter localeNameParam = new Parameter(UILanguageSelector.LOCALE_NAME, "") ;
30     Parameter[] changeLocaleParams = { UILanguageSelector.CHANGE_PARAM, localeNameParam } ;
31     w.write("<div class='UILanguageSelector'>") ;
32     Iterator JavaDoc i = uiSelector.getLocaleConfigs().iterator() ;
33     while(i.hasNext()) {
34       LocaleConfig config = (LocaleConfig) i.next() ;
35       localeNameParam.setValue(config.getLocaleName()) ;
36       linkRenderer_.render(w, uiSelector, res.getString("UILanguageSelector.image." + config.getLocaleName()), changeLocaleParams) ;
37     }
38     w.write("</div>") ;
39   }
40 }
Popular Tags