10-19-2010 10:32 AM
Hi everyone,
I'm having an issue with the DateField control.
I am setting the initial value of the control to be Long.MIN_VALUE - according to the documentation, this will display a blank date. I need to do this as the user should have the option to NOT select a date if they don't want to.
If I click the blank date, the picker will pop up, allowing me to select a date. This defaults to today's date. If I pick a date/time other than the default value and click OK, the date/time displayed by the form updates correctly. However, if I keep with the default value and just click OK (therefore accepting the default), the date/time is NOT displayed, and the Long.MIN_VALUE date is returned if I call getDate() on the DateField.
I have attached a field change listener and can confirm that the event is not fired when you accept the default value when coming from a blank date/time. However, if you select another date, it is fired ok.
This seems like a bug in the control to me, so I was wondering if anyone else has encountered this problem, or if anyone has any suggestions as to how to get around it?
The code I've written to create the DateField is as follows:
long initialDateTime = Long.MIN_VALUE;
DateField dateField = new DateField("Select date", initialDateTime, DateField.DATE_TIME);
Thanks in advance!
Glenn
10-19-2010 10:41 AM
welcome to the support forums.
this looks like a bug to me. you can report it here:
https://www.blackberry.com/jira/secure/Dashboard.j
as a workaround you could maybe overwrite navigationclick and set the default value.
or place a checkbox nearby allowing the user to activate/deactivate the date field, initializing it with the current date.
10-20-2010 04:39 AM
Hi Simon,
Thanks for your welcome and your help!
I've overridden the navigationClick method and made it replace the date value with the current time if it is blank. I've also added a button to the right of the field that will "clear" the date by putting Long.MIN_DATE in there. This will do for now. I'm going to submit a bug for this as well.
Thanks a lot for your suggestion!
Glenn
02-03-2011 01:39 AM
Hi,
I am Facing same issue. solution please???
Regards
Suresh Kerai