I would like to change the default value behaviour of a DateField so that instead of setting the default value to the current time I have some control over whether the time is set to the start of the day or the end of the day.
Since my business logic/requirement is that the field is optional and can be null, I don’t want to specify the default value in the model object, What I’m looking for is the default value is only set after the user has clicked on the popped up the date field widget.
I’ve read through the code of DateField and the default value seems to be controlled by the private method getCalendar(). This method seems to say if getValue() is null then use a Calendar with the current time. I think I could get the behaviour I want if this method was protected and I override it.
So short of building from the source, is there another approach I might use? Perhaps something around event listeners, or maybe the setInternalValue() method??
Latest version of MDateField in
Viritin just got this feature
Usage example in GitHub . The datefield in core should definitely have this kind of feature as well.
Hello Matti,
thanks for your plugin.
I jsut downloaded the Viritin plugin (currently 2.4) to incorporate it in my Vaadin 8.3.2 framwork project.
But I dont find the MDateField class under the xxx.viritin.fiels pacakge in the javadoc.
My eclipse dont find it either.
I would have loved to give it a try, as the 8.3.2 DateField, even set with a display Formater, always loose the time part of my timestamp (here comming from a database column).
Did you removed the MDateField ?