I answer the same question some time ago. You can check an small
tutorial here:
http://ctasada.blogspot.com/2010/08/gwt-extend-datepickercalendarview.html

I hope it helps.

On Mar 8, 2:09 pm, ALB-PSP-DV1 <[email protected]> wrote:
> I'm new to GWT. I'm using GWT 2.1.1. I have requirement to disable
> certain dates in the datepicker (disable dates before 15Aug2010 and
> after 15Aug2011).
>
> The dates are however not disabled in datepicker, the user is able to
> select 16Aug2011, 17Aug2011 etc for the first time. Only after
> selecting this date they are disabled.
>
> Kindly let me know the mistake I'm doing.
>
> Code:
>
> class CustomDateFormat extends DateBox.DefaultFormat
> {
>     public CustomDateFormat(DateTimeFormat dateTimeFormat){
>         super(dateTimeFormat);
>     }
>
>     @Override
>     public Date parse(final DateBox dateBox, final String dateText,
> boolean reportError)
>     {
>          Date date = null;
>          try {
>            if (dateText.length() > 0) {
>              date = getDateTimeFormat().parse(dateText);
>            }
>          } catch (IllegalArgumentException exception) {
>            try {
>              date = new Date(dateText);
>            } catch (IllegalArgumentException e) {
>              if (reportError) {
>                dateBox.addStyleName("dateBoxFormatError");
>              }
>            }
>          }
>          final Date selDate = date;
>         dateBox.getDatePicker().addShowRangeHandlerAndFire(new
> ShowRangeHandler<Date>() {
>                 @Override
>                 public void onShowRange(ShowRangeEvent<Date> event) {
>                         if (selDate != null){
>                         Date minDate =  
> getDateTimeFormat().parseStrict("15Aug2010");
>                         Date maxDate =  
> getDateTimeFormat().parseStrict("15Aug2011");
>
>                         if (selDate .before(minDate) || selDate 
> .after(maxDate)) {
>
> dateBox.getDatePicker().setTransientEnabledOnDates(false,date);
>                         }
>                  }
>                 }
>
>         });
>         return date;
>     }}
>
> //set the format to be used by date picker
> dateBox.setFormat(new
> CustomDateFormat(DateTimeFormat.getFormat("ddMMMyy")));

-- 
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.

Reply via email to