开发者

Does Tapestry 5 Have composite components

I'm trying to write a composite component like this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" xmlns:p="tapestry:parameter">
    <t:select t:id="yearField" t:value="year" t:blankOption="always" t:model="yearModel" class="select"/>
    <t:select t:id="monthField" t:value="mont开发者_JAVA百科h" t:blankOption="always" t:model="monthModel" class="select"/>
</t:container>

So that I can use it like this

<t:dateselector t:value="testDate"></t:dateselector>

But I can't find exactly which method to use to get the individual elements and construct the date element. Any ideas?


You'll have to add a value parameter of type Date and getters and setters for the year and monthproperties in your component class:

public class MyDatePicker {
   @Parameter
   private Date value;

   public Integer getYear() { ... }
   public void setYear(Integer year) { ... }
   public Integer getMonth() { ...}
   public void setMonth(Integer month) { ... }

}

You could use Java's Calendar or the vastly superior Joda Time to get/set the different parts of your date value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜