On 14 avr, 16:27, Peterman <[email protected]> wrote:
> Hi
>
> I'am working with the DateBox component: show a calendar when you
> click on a box. But I have a problem: the listener onValueChange
> doesn't work like in the componente DatePicker. This is my code:
>
> DateBox dateBox = new DateBox();
>
> /*dateBox.setFormat(new DateBox.DefaultFormat
> (DateTimeFormat.getFormat
> ("MMM dd, YYYY HH:mm aaa")));*/
>
> dateBox.addValueChangeHandler(new ValueChangeHandler<Date>() {
> public void onValueChange(ValueChangeEvent<Date> event)
> {
>
> Window.alert("onValueChange datebox");
> /*Date date = dateBox.getValue();
> try
> {
> String dateString =
> DateTimeFormat.getMediumDateFormat
> ().format(date);
> okButtton.setEnabled(true);
> Window.alert("okbutton a true");
> }
> catch (Exception e)
> {
> Window.alert("okbutton a false");
> Window.alert(e.getMessage());
> okButtton.setEnabled(false);
> }*/
>
> }
> });
>
> This code in DatePicker works. Anybody knows why? Maybe it is a bug of
> this componente?
Seems related to issues 1634 and 3553:
http://code.google.com/p/google-web-toolkit/issues/detail?id=1634
http://code.google.com/p/google-web-toolkit/issues/detail?id=3553
namely, when you click on the popup calendar, the textbox looses focus
and fires a value change event (then only the click on the popup
calendar has a chance to select a date, thus set the datebox's value
and fire the expected value change event).
(I don't understand you try/catch check with format(): getValue will
only return a non-null value if the textbox value is a date in the
appropriate format; could it be your actual problem? dateBox.getValue
() being null?)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---