0 down vote favorite
share [fb] share [tw]
I have developed the code to change the gwt datepicker CSS for a week
for a selected date.
i am able to change the whole week colour, but i move to next week or
previous week and return back to current date, then the css on
weekends is removed but on remaining 5 days, it there.
I am attaching both the classes and css-classes which i am using.
custom datepicker class
import java.util.Date;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.logical.shared.ShowRangeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.i18n.client.constants.DateTimeConstants;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.datepicker.client.DatePicker;
/**
public class CustomeDatePicker extends DatePicker {
private Date date;
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
@Override
public HandlerRegistration addShowRangeHandler(
ShowRangeHandlerDate handler) {
if(getDate()!=null){
setWeekStyle(getDate());
}
return super.addShowRangeHandler(handler);
}
public CustomeDatePicker() {
}
@Override
public void addStyleToDates(String styleName, Date date) {
super.addStyleToDates(customeDatePicker, date);
}
@Override
public HandlerRegistration addValueChangeHandler(
ValueChangeHandlerDate handler) {
if(getDate()!=null){
setWeekStyle(getDate());
}
return super.addValueChangeHandler(handler);
}
public void setWeekStyle(Date date) {
setDate(date);
DateTimeConstants constants =
LocaleInfo.getCurrentLocale().getDateTimeConstants();
int firstDay =
Integer.parseInt(constants.firstDayOfTheWeek()) - 1;
int offset = firstDay - date.getDay();
date.setDate(date.getDate() + offset);
// hun tak
/* this.removeStyleFromDates(this.getStyleName(), date);*/
Window.alert(setWeekStyle);
/*this.removeStyleFromDates(datePickerDayIsWeekend, date);*/
this.addStyleToDates(customeDatePicker, date);
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
/* this.removeStyleFromDates(datePickerDayIsWeekend, date);
*/ this.addStyleToDates(customeDatePicker, date);
this.getElement().getStyle().setBackgroundColor(red);
this.removeStyleFromDates(datePickerDayIsWeekend, date);
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
this.addStyleToDates(customeDatePicker, date);
this.getElement().getStyle().setBackgroundColor(red);
this.removeStyleFromDates(datePickerDayIsWeekend, date);
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
this.addStyleToDates(customeDatePicker, date);
this.getElement().getStyle().setBackgroundColor(red);
this.removeStyleFromDates(datePickerDayIsWeekend, date);
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
this.addStyleToDates(customeDatePicker, date);
this.getElement().getStyle().setBackgroundColor(red);
this.removeStyleFromDates(datePickerDayIsWeekend, date);
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
this.addStyleToDates(customeDatePicker, date);
this.getElement().getStyle().setBackgroundColor(red);
this.removeStyleFromDates(datePickerDayIsWeekend, date);
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
this.addStyleToDates(customeDatePicker, date);
this.getElement().getStyle().setBackgroundColor(red);
this.removeStyleFromDates(datePickerDayIsWeekend, date);
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
Window.alert(itjay rakh);
}
}
the entry class
import java.util.Date;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.ShowRangeEvent;
import com.google.gwt.event.logical.shared.ShowRangeHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.datepicker.client.DatePicker;
/**
* Entry point classes define codeonModuleLoad()/code.
*/
public class Gwtproj implements EntryPoint {
/**
* The message displayed to the user when the server cannot be
reached or
* returns an error.
*/
private static final String SERVER_ERROR = An