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

BeanEditForm Component


Our current collection of celebrities is tiny, and it would be a good idea to provide in the application functionality for adding new celebrities. Let's begin by adding a template and a page class for a new page named AddCelebrity. Add to the page class a single persistent property named celebrity, so that its code looks like this:

package com.packtpub.celebrities.pages;
import com.packtpub.celebrities.model.Celebrity;
import org.apache.tapestry.annotations.Persist;
public class AddCelebrity
{
@Persist
private Celebrity celebrity;
public Celebrity getCelebrity()
{
return celebrity;
}
public void setCelebrity(Celebrity celebrity)
{
this.celebrity = celebrity;
}
}

In the page template, declare one single component of type BeanEditForm and let its id be the same as the name of the property of the page class, in our case, celebrity:

<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head>
<title>Celebrity Collector: Adding New
Celebrity...