Is there a way to select the year in a DateField in the same way as hours or minutes? This would facilitate the selecting a birthday significantly.
How do you mean? Removing the calendar and choosing only the year, or having a dropdown which you can click the year from.
For first option, check out
http://demo.vaadin.com/sampler/#DateResolution
and choose reslution: Year.
For the second, make a select-component with the years you want to be in the range.
ComboBox year = new ComboBox();
for(int i = 1900; i<=2010; i++){
year.addItem(i);
}
Change to a NativeSelect if you rather want that look & feel.
Third option is of course to have a TextField with a Validator.
I use the Calendar Popup with DayResolution like
http://demo.vaadin.com/sampler/#DateResolution
But selecting an birthday like 04.06.1950 is circuitous.
Selecting the year from an combobox in the “Header”
of the Calender Popup could be a solution.
Let alone selecting an earlier date…
Maybe clicking the year in the calendar could let the user to edit the number directly? This would be usable and easy to implement (just put the year number in a text input field, style it to look like the current calendar and switch to a style that communicates that the number can be edited when the field has focus.
Created Make year editable in DateField caledar popup · Issue #1217 · vaadin/framework · GitHub
This made a good opportunity to try out the
CustomField
add-on, so I created a little
example
. CustomField seems to make server-side customization of fields really easy. It should probably be part of the core library, as it doesn’t even grow the client-side code.
The NativeSelect feels better for this purpose than ComboBox.
You can make such a composite pop up by putting it inside a PopupView.