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

Internationalization of Images


First of all, let us simply display an image of German flag next to the link. Find an appropriate image (or simply take the one named flag.gif from the source code package for this chapter) and put it into the assets folder, where we already have our styles.css file. Place a regular<img> tag somewhere in the page template, but the source for it will be provided by an expansion, like this:

<p align="right">
<img src="${flag}"/>
<t:actionlink t:id="switchlocale">
${localeLabel}
</t:actionlink>
</p>

Now we need to add some code to the page class in order to make the flag.gif image available to the page template. Here is the code that will do the job:

@Inject
@Path("context:/assets/flag.gif")
private Asset flag;
public Asset getFlag()
{
return flag;
}

This way you can obtain any kind of asset in your code—image, stylesheet, text or XML file—anything at all, as long as it is located in an appropriate directory of your application...