HomeApache The DatePicker and Shell Components of Apache Tapestry
The DatePicker and Shell Components of Apache Tapestry
In the previous article in this series we came to adding a component for accepting a date input, to specify the date of birth for the newly added celebrity. DatePicker, a standard Tapestry component, is an excellent choice for this, and we are going to learn today how to add a DatePicker to a page.
However, DatePicker has a few downsides, and I am going to mention them, preparing you for the necessity of creating your own custom component for date input. Before building such a custom component, however, we'll need to have a clear understanding of the PropertySelection component and the IPropertySelectionModel interface -- this will be the topic for the next issue.
To begin with, let's add a DatePicker to the AddCelebrity page. Mark the remaining text box (labeled "Date of Birth") as a Tapestry component:
<td>Date of Birth:</td>
<input type="text" jwcid="dateOfBirth"/>
Configure the new component in the page specification:
<component id="dateOfBirth" type="DatePicker">
<binding name="value" value="dateOfBirth"/>
It has a familiar value binding. The only difference with what we dealt with before is that the data type for this binding has to be java.util.Date. Let's configure a corresponding property in the page class:
public abstract Date getDateOfBirth();