简体   繁体   中英

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.

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);  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM