Book Image

Tapestry 5: Building Web Applications

Book Image

Tapestry 5: Building Web Applications

Overview of this book

Table of Contents (17 chapters)
Tapestry 5
Credits
About the Author
About the Reviewers
Preface
Foreword
Where to Go Next

Creating a Universal Locale Switcher


Every internationalized application needs to have some solution for switching the current locale, and it would be nice to have a universal component for this purpose. Let's try to define what such a component should do:

  • It should find out which locales are supported by the application.

  • It should display a drop-down box with an option for each supported locale.

  • It should also display a flag image for the currently selected locale.

In a way, the logic of this component will be opposite of the logic of the English/German locale switcher we created in the previous chapter, because it will display the flag and the label for the currently selected locale, not for the alternative one (as there potentially can be more than one alternative locale). The following is what we want to achieve:

At the first stage, let us simplify our task and pass a list of supported locales to the new component as a parameter. Later we shall see what it will take to obtain this list from...