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

More Than One Submit Button


Many Web applications give their users an opportunity to quickly "erase" the information they have just entered in case they change their mind. We can also provide a button for this purpose—let it be labeled Reset— using a second Submit component. Let's position it next to the existing Submit button , using the following code:

<input type="submit" t:type="submit" t:id="submitButton"
value="Submit"/>
<input type="submit" t:type="submit" t:id="resetButton"
value="Reset"/>

And of course, we need an event handler for the new component:

@OnEvent(component="resetButton")
void onResetButton()
{
userName = null;
password = null;
email = null;
gender = null;
subscribe = false;
}

We are simply assigning default values to all the persistent properties here. Test the application, and everything should work fine.

This chapter is becoming rather long, but there is only one component left of those we have planned to learn, and this one is very useful.