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 226 | Next

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

He or she will probably look around in
search for some hint, and if they see a link saying Deutsch, they will certainly click
on it. So let's change the text of the link so that it says Deutsch when the current
locale of the application is English, and English when the current locale of the
application is German.
Here is how the link will look now in the page template:



${localeLabel}


And here is the code that will make it work:
@Persist
private String localeLabel;
public String getLocaleLabel()
{
if (localeLabel == null)
{
if (currentLocale.equals(Locale.GERMAN))
{
localeLabel =
new Locale("en").getDisplayName(Locale.ENGLISH);
}
else
{
localeLabel =
new Locale("de").getDisplayName(Locale.GERMAN);
}
}
Internationalization and Localization
[ 186 ]
return localeLabel;
}
@OnEvent(component="switchlocale")
void changeLocale()
{
localeLabel = currentLocale.getDisplayName(currentLocale);
if (currentLocale.equals(Locale.GERMAN))
{
persistentLocale.set(Locale.ENGLISH);
}
else
{
persistentLocale.set(Locale.GERMAN);
}
}
Run the application, and it should work and look quite well now.


Pages:
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6