apache.tapestry.services.PersistentLocale;
public class LocaleSwitcher
{
Chapter 8
[ 227 ]
@Parameter(defaultPrefix = "literal", required = true)
private String supportedLocales;
@Inject
private PersistentLocale persistentLocale;
public Locale getSelectedLocale()
{
return persistentLocale.get();
}
public void setSelectedLocale(Locale selectedLocale)
{
persistentLocale.set(selectedLocale);
}
public SelectModel getLocaleModel()
{
return new LocaleSelectModel(supportedLocales);
}
public ValueEncoder getLocaleEncoder()
{
return new LocaleEncoder();
}
}
To complete the work on the component, we now need to take care of the flag
images. Create a new package named com.packtpub.celebrities.components.
images. This will basically create an images subfolder in the directory structure
where the component class was created. Put as many flag images into this package as
you wish, making sure that the default one is named flag.gif, while all the others
have an appropriate suffix in their file name, like flag_de.gif, flag_es.gif and so
on. In the code package for this chapter you will find two flags??”British and German.
In Eclipse, you can simply copy these images and paste them into the package
straight in the IDE.
Pages:
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284