Calendar year range can be set ?

Our app has to follow govenment regulation that only allow user to print document in certain years. How to set the calendar (actually it is PopupDateField) year range ? For example, only show year from 1950-2011. Like in jQuery datepicker, I can do "yearRange: “-20 : +1”, then the pull down menu only shows year go back 20 and future 1.

Vaadin UI calender does not has a pull down menu, which allow you quick pick the year instead of using many clicks of “<<” or “>>” sign.




there is currently no such feature in the (Popup)DateField. Please make a feature request ticket to the Vaadin trac about this.

To implement this yourself, you may consider adding a ValueChangeListener to the DateField which would check the user-set value and correct it if necessary, thus preventing the user from going out of the year limits you choose. Another option could be writing a Validator which would check that the selected date falls within the year range, and if not, show a validation error in the UI.

If you really need to prevent the non-valid year selection completely in the browser, you probably must write your own widget or at least extend the default datefield/calendar widget. In this case, check out VPopupCalendar and VCalendarPanel classes.


Thanks, I will sumbit the ticket.