Change page

After the user selects a language, the application switches to the Change page for a response, which includes a link back to the Home page (as a localized image button).

Figure 11.8. Change.html

<jwc id="border">

Congratulations, you've changed the locale to <jwc id="insertLocaleName"/>.

<p><jwc id="home"><jwc id="chooseAgainImage"/></jwc>

</jwc>

This template combines with the specification that identifies the images.

Figure 11.9. Change.jwc

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE specification PUBLIC 
  "-//Howard Ship//Tapestry Specification 1.1//EN" 
  "http://tapestry.sf.net/dtd/Tapestry_1_1.dtd">
<specification class="tutorial.locale.Change">
  
  <component id="border" type="Border"/>
  
  <component id="insertLocaleName" type="Insert">
    <binding name="value" property-path="localeName"/>
  </component>
  
  <component id="home" type="Page">
    <static-binding name="page">Home</static-binding>
  </component>
  
  <component id="chooseAgainImage" type="Image">
    <binding name="image" property-path="assets.choose-again"/>
  </component>
  
  <context-asset name="choose-again" path="/images/locale/ChooseAgain.gif"/>

</specification>

This is similar to the previous example, in that we've provided four versions of the ChooseAgain.gif image asset. However, we've put the images in a different place. This time, the asset is a context asset, an asset that is visible to the servlet container. In this example, the file ChooseAgain.gif is located in the /images/locale directory of the WAR. Tapestry makes sure that the correct prefix (/tutorial) is prepended to the path when the HTML is rendered.

Context assets are the most common assets used. Private assets (as used on the Home page) are used mostly when creating libraries of components for reuse. When building an application that stands on its own, context assets are easier and more efficient.