*/
public void doSave(Event event) {
org.zkoss.calendar.Calendars cals = getCalendarCtrl().getCal();
MySimpleCalendarEvent ce = (MySimpleCalendarEvent) editEventWindow.getAttribute("ce");
Calendar cal = Calendar.getInstance(cals.getDefaultTimeZone());
Date beginDate = ppbegin.getValue();
Date endDate = ppend.getValue();
beginDate.setSeconds(0);
endDate.setSeconds(0);
if (!ppallDay.isChecked()) {
String[] times = ppbt.getSelectedItem().getLabel().split(":");
cal.setTime(beginDate);
cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(times[0]));
cal.set(Calendar.MINUTE, Integer.parseInt(times[1]));
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
beginDate = cal.getTime();
times = ppet.getSelectedItem().getLabel().split(":");
cal.setTime(endDate);
cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(times[0]));
cal.set(Calendar.MINUTE, Integer.parseInt(times[1]));
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
endDate = cal.getTime();
} else {
cal.setTime(beginDate);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
beginDate = cal.getTime();
cal.setTime(endDate);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
endDate = cal.getTime();
}
if (!beginDate.before(endDate)) {
alert("The end date cannot be before/equal than begin date!");
return;
}
String[] colors = ((String) ppcolor.getSelectedItem().getValue()).split(",");
ce.setHeaderColor(colors[0]);
ce.setContentColor(colors[1]);
ce.setBeginDate(beginDate);
ce.setEndDate(endDate);
ce.setTitle(txtb_title.getValue());
ce.setContent(ppcnt.getValue());
ce.setLocked(pplocked.isChecked());
// prepare the backend Bean
MyCalendarEvent calEvt = getCalendarEventService().getNewCalendarEvent();
calEvt.setId(ce.getId());
calEvt.setSecUser(ce.getUser());
calEvt.setVersion(ce.getVersion());
calEvt.setTitle(ce.getTitle());
calEvt.setContent(ce.getContent());
calEvt.setBeginDate(ce.getBeginDate());
calEvt.setEndDate(ce.getEndDate());
calEvt.setHeaderColor(ce.getHeaderColor());
calEvt.setContentColor(ce.getContentColor());
// Save the calendar event to database
try {
getCalendarEventService().saveOrUpdate(calEvt);