[Tapestry5.0.6]DateFieldDemo

DateFieldDemo.tml
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<head><title>DateField Demo</title></head>
<body>
  <h1>DateField Demo</h1>

  <t:form>
    <t:errors />

    <div class="t-beaneditor">

      <div class="t-beaneditor-row">
        <t:label for="birthday" />
        <t:datefield t:id="birthday" />
      </div>


      <div class="t-beaneditor-row">
        <input type="submit" value="Go" />
      </div>

    </div>
  </t:form>

  <t:if test="birthday">
    <hr />
    <p>
      Birthday:
      [<t:output value="birthday" format="dateFormat" />]
    </p>
  </t:if>

</body>
</html>


DateFieldDemo.java


package org.test.pages;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.beaneditor.Validate;

public class DateFieldDemo
{
    @Persist
    private Date _birthday;

    @Validate("required")
    public Date getBirthday()
    {
        return _birthday;
    }

    public void setBirthday(Date birthday)
    {
        _birthday = birthday;
    }

    public DateFormat getDateFormat()
    {
        return new SimpleDateFormat("MM/dd/yyyy");
    }
}

你可能感兴趣的:(java,apache,tapestry)