1 5 package org.exoplatform.faces.user.renderer.html; 6 7 import java.util.ResourceBundle ; 8 import java.io.IOException ; 9 import java.util.Iterator ; 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 23 public class LanguageSelectorRenderer extends HtmlBasicRenderer { 24 25 final public void encodeChildren( FacesContext context, UIComponent component ) throws IOException { 26 UILanguageSelector uiSelector = (UILanguageSelector) component ; 27 ResponseWriter w = context.getResponseWriter() ; 28 ResourceBundle 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 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 |