If you're using a DateBox, you can define a custom Format with your
own parsing rules with:


     setFormat(new CustomDateFormat(DateTimeFormat.getFormat
(pattern)));


http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/com/google/gwt/user/datepicker/client/DateBox.html#setFormat(com.google.gwt.user.datepicker.client.DateBox.Format)


    private static final String DATE_BOX_FORMAT_ERROR =
"dateBoxFormatError";

    private class CustomDateFormat extends DateBox.DefaultFormat
    {
        public CustomDateFormat(DateTimeFormat dateTimeFormat)
        {
            super(dateTimeFormat);
        }

        @Override
        public Date parse(DateBox dateBox, String dateText, boolean
reportError)
        {
            Date date = null;
            try
            {
                if (dateText.length() > 0)
                {
                    date = getDateTimeFormat().parseStrict(dateText);
                }
            }
            catch (Exception exception)
            {
                // According to the documentation, this should be an
                // IllegalArgumentException, but bugs in
DateTimeFormat
                // can cause other exceptions to be thrown, for
example:
                // java.lang.StringIndexOutOfBoundsException: String
index out of range: 0
                // at java.lang.String.charAt(String.java:558)
                // at
com.google.gwt.i18n.client.DateTimeFormat.parseInt(DateTimeFormat.java:
1415)
            }
            if (date == null)
            {
                // If there are other formats you want to support, do
the parsing here
            }
            if (date != null)
            {
                // If there are dates that you want to disallow, set
date to null here
            }
            if (date == null && reportError)
            {
                dateBox.addStyleName(DATE_BOX_FORMAT_ERROR);
            }
            return date;
        }
    }


On Jan 19, 8:02 am, Mark Davis <[email protected]> wrote:
> Hi,
>
> I need to disable specified dates in DatePicker.
>
> What is the best way to do it?
>
> thanks in advance,
> Mark
-- 
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