Dnyani
Dnyani

Reputation: 1253

How to use DatePicker in wicket which have month and year increment option?

I am using DatePicker in java wicket like this,

DateTextField txtInvoiceDate=new DateTextField("txtInvoiceDate",new PropertyModel<Date>(objmodel, "txtInvoiceDate"),new PatternDateConverter("dd/MM/yyyy", true));
        txtInvoiceDate.add(new DatePicker());
        add(txtInvoiceDate);  

It's shows only month increment option but I want year increment option also.
so please give me any kind of advise or guideline.

Upvotes: 1

Views: 2652

Answers (1)

psicopoo
psicopoo

Reputation: 1676

I've yet to discover a built in functionality for incrementing the year, but there is a pretty easy way to enable setting the year more easily. Just override enableMonthYearSelection.

DateTextField txtInvoiceDate=new DateTextField("txtInvoiceDate",new PropertyModel<Date>(objmodel, "txtInvoiceDate"),new PatternDateConverter("dd/MM/yyyy", true));
DatePicker picker = new DatePicker(){
    @Override
    protected boolean enableMonthYearSelection() {
        return true;
    }
};
txtInvoiceDate.add(new DatePicker());
add(txtInvoiceDate);  

Upvotes: 1

Related Questions