Hello everyone,
I am using GWT 2.0 and having trouble with the DatePicker. There is a
lot of conflicting information on the web about the GWT DatePicker
object, and I suspect most of it was written for GWT 1.6.
I am trying to implement a simple DatePicker (I was thinking something
along the lines of Expedia.com or Travelocity.com). I have it kind of
working--my DatePicker can populate my TextBox with the selected date.
However, if I click on the SAME date as selected, the DatePicker will
not disappear:
final DatePicker datePicker = new DatePicker();
final TextBox dateLabel;
dateLabel = new TextBox();
datePicker.addValueChangeHandler(new ValueChangeHandler() {
public void onValueChange(ValueChangeEvent event) {
Date date = (Date) event.getValue();
String dateString =
DateTimeFormat.getMediumDateFormat().format(date);
dateLabel.setText(dateString);
datePicker.setVisible(false);
}
});
datePicker.setVisible(false);
dateLabel.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
datePicker.setVisible(true);
}
});
// Set the default value
datePicker.setValue(new Date(), true);
searchTable.setWidget(0, 0, dateLabel);
searchTable.setWidget(0, 1, datePicker);
Since clicking the same date will not fire a ValueChangeEvent, the
picker stays. It seems to me there must be an easier, more standard
way of implementing the datePicker. I was thinking something like
what's already implemented in http://datepickerdemo.appspot.com/,
although I was unable to find/figure out how they implemented, or at
least more useful information on the DatePicker object in GWT 2.0.
Thanks so much in advance,
Pedro
--
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.