public DayModel getDefaultDay(Reference cal) {

    for (DayModel day : cal.getDefaultWeekDays()) {
      if (day.getDefaultDay()) {
        return day;
      }
    }
    return null;
  }
  public ModelAndView onSubmit(
      HttpServletRequest request,
      HttpServletResponse response,
      Object command,
      BindException errors)
      throws Exception {
    if (log.isDebugEnabled()) {
      log.debug("entering 'onSubmit' method...");
    }

    DefaultWeekDay defaultWeek = (DefaultWeekDay) command;
    Locale locale = request.getLocale();
    boolean isNew = defaultWeek.getId() == null;
    if (request.getParameter("delete") != null) {
      Reference cal = defaultWeek.getRegion();
      cal.getDefaultWeekDays().remove(defaultWeek);
      defaultWeek.setRegion(null);
      this.referenceManager.saveReference(cal);

      saveMessage(request, getText("defaultWeek.deleted", locale));
      return new ModelAndView("redirect:defaultWeeks.html", "region", cal.getId());
    } else {
      if (defaultWeek.getNonWorkingDay() == null) defaultWeek.setNonWorkingDay(false);
      if (!isNew && defaultWeek.getNonWorkingDay() && defaultWeek.getWorkHourRanges() != null) {
        for (WorkHourRange w : defaultWeek.getWorkHourRanges()) {
          w.setDay(null);
        }
        defaultWeek.getWorkHourRanges().clear();
      }

      this.calendarDateManager.saveCalendarDate(defaultWeek);

      String key = (isNew) ? "defaultWeek.added" : "defaultWeek.updated";
      saveMessage(request, getText(key, locale));

      return new ModelAndView("redirect:editDefaultWeek.html", "id", defaultWeek.getId());
    }
  }