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

Alexander Kolesnikov

"Tapestry 5: Building Web Applications"

Tapestry has a special service
named PersistentLocale. To get access to this service we simply inject it into the
page. This is how it looks:
@Inject
private PersistentLocale persistentLocale;
And then we use the service's set method to set the new locale, like this:
persistentLocale.set(Locale.GERMAN);
Chapter 7
[ 183 ]
It's that simple! However, to make this functionality work, we need to run the
above line of code in some event handler. For simplicity, let's use the ActionLink
component at this stage.
We could use two links, one of them saying Switch to German, another Switch to
English, but, it will be slightly closer to a real life functionality if we use just one link,
Switch Locale, and it will do the job whatever the current locale is. Here is how such
a link could look in the page template:



Switch Locale


Before writing an event handler for this link, let's inject into the page yet another
resource??”the current application's locale:
@Inject
private Locale currentLocale;
And here is the event handler:
@OnEvent(component="switchlocale")
void changeLocale()
{
if (currentLocale.equals(Locale.


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