2011-09-02 6 views
3

는 나는이합니까 태피스트리 5 유무 복합 구성 요소

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

처럼 사용할 수 있도록이

<!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="month" t:blankOption="always" t:model="monthModel" class="select"/> 
</t:container> 

같은 복합 구성 요소를 쓰기 위해 노력하고있어하지만 정확하게 찾을 수없는 메서드를 사용하여 개별 요소를 가져오고 날짜 요소를 구성합니다. 어떤 아이디어?

답변

3

당신은 입력 Dateyearmonth 속성에 대한 getter 및 setter의 valueparameter를 추가해야합니다 귀하의 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) { ... } 

} 

당신은 얻을 자바의 Calendar 또는 훨씬 뛰어난 Joda Time를 사용할 수 있습니다/날짜 값의 다른 부분을 설정하십시오.

+1

폼 컨트롤 구성 요소는 다른 유형의 구성 요소보다 약간 복잡합니다 ... 초기 렌더링 대 최종 폼 제출을 알고 있어야합니다. 예를 들어 제출시 value 매개 변수가 null 인 경우를 처리 할 수 ​​있습니다. http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/SubmitNotifier.html 구성 요소가 도움이 될 수 있습니다. –

+0

도움에 감사드립니다. 당신이 제안한대로 정확히했는데 완벽하게 작동했습니다. –

관련 문제