Friday, September 2, 2011

Unable to disable a range of date in the DatePicker component.

I am trying to disable all the date in the DatePicker GWT component,
here is my sample of code :

datePicker.addShowRangeHandler(new ShowRangeHandler() {

public void onShowRange(ShowRangeEvent<Date> event) {
System.out.println("First date : " + event.getStart());
System.out.println("Last date : " + event.getEnd());

System.out.println("First date from date picker : " +
datePicker.getFirstDate());
System.out.println("Last date from date picker : " +
datePicker.getLastDate());

// Disable all the date shown by the Calendar
List<Date> dateList = new ArrayList<Date>();
Date currentDate = event.getStart();

while(!currentDate.after(datePicker.getLastDate())) {
Date updateDate = CalendarUtil.copyDate(currentDate);
dateList.add(updateDate);
CalendarUtil.addDaysToDate(currentDate, 1);
}

for(Date date : dateList) {
System.out.println("Date selected : " + date);
System.out.println("date visibility : " +
datePicker.isDateVisible(date));
} }

});

Date visibility is always false , it keep telling me that all the date
are not visible, but it should be true since it' between the first
date and last date, anybody know a way to disable date in calendar?,
so if tried the method setTransientOnEnables() on the datePicker for
any of the date I keep getting an exception as the date arenot
visible.

I had tried also impleenting my own DefaultClendarView but it requires
protected class which is not available by GWT.

Thanks.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment