SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 269 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

locales = locales;
}
public List getOptionGroups()
{
return null;
}
public List getOptions()
{
if (locales != null)
{
List locList =
Chapter 8
[ 225 ]
new ArrayList();
String[] locs = locales.split(",");
for (String str : locs)
{
locList.add(new LocaleOptionModel(
new Locale(str)));
}
return locList;
}
return null;
}
}
When creating the LocaleSelectModel, we suppose that the list of supported
locales, passed as a parameter for the constructor, is a string containing language
abbreviations separated by commas, like "en,de". Finally, here is an implementation
of ValueEncoder for Locale:
package com.packtpub.celebrities.util;
import java.util.Locale;
import org.apache.tapestry.ValueEncoder;
public class LocaleEncoder implements ValueEncoder
{
public String toClient(Object obj)
{
Locale loc = (Locale) obj;
return loc.getLanguage();
}
public Object toValue(String str)
{
return new Locale(str);
}
}
Now let's create the component's template, LocaleSwitcher.tml. It might look
like this:


257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
drukarki Hosting tanio Forum GSM Oprawy oświetleniowe Angielskie ciasteczka do herbaty -