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

The If and Checkbox Components


Let's say during registration we want to give the users an opportunity to subscribe to our newsletter. For this, we are going to add a check box to the registration form, like the one shown here:

To make the interface slightly more complex, and also to give me an opportunity to show you yet another component, let's say that as soon as the user clicks on the check box, the check box should disappear, and a text box for accepting the user's email should appear instead:

Here is a fragment of the page template that will do the job:

<tr>
<t:if t:test="subscribe">
<td><t:label t:for="email"/></td>
<td>
<input type="text" t:type="textfield" t:id="email"
t:value="email"/>
</td>
<t:parameter t:name="else">
<td colspan="2">
<input type="checkbox" t:type="checkbox"
t:value="subscribe"
onclick="this.form.submit()"/>
Check the box to subscribe to our Newsletter.
</td>
</t:parameter>
<...