Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
New Contributor
DynamicDonut
Posts: 2
Registered: ‎10-19-2010

DateField field changed issue

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

Please use plain text.
Developer
simon_hain
Posts: 13,826
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: DateField field changed issue

welcome to the support forums.

 

this looks like a bug to me. you can report it here:

https://www.blackberry.com/jira/secure/Dashboard.jspa

 

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.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
New Contributor
DynamicDonut
Posts: 2
Registered: ‎10-19-2010

Re: DateField field changed issue

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

Please use plain text.
Contributor
keraisureshv
Posts: 48
Registered: ‎03-04-2009

Re: DateField field changed issue

Hi,

  I am Facing same issue.  solution please???

 

Regards

Suresh Kerai 

Please use plain text.