@Override
 protected boolean validateFormLogic(@SuppressWarnings("unused") final UserRequest ureq) {
   // validate date-fields for correct date and start < end date
   dateStart.clearError();
   dateEnd.clearError();
   boolean isInputValid = true;
   if (dateEnd.hasError() || dateEnd.getDate() == null) {
     dateEnd.setErrorKey("filter.date.invalid", null);
     isInputValid = false;
   }
   if (StringHelper.containsNonWhitespace(dateStart.getValue())
       && (dateStart.hasError() || dateStart.getDate() == null)) {
     dateStart.setErrorKey("filter.date.invalid", null);
     isInputValid = false;
   } else if (isInputValid
       && StringHelper.containsNonWhitespace(dateStart.getValue())
       && dateStart.getDate().after(dateEnd.getDate())) {
     dateStart.setErrorKey("filter.date.invalid.afterend", null);
     isInputValid = false;
   }
   return isInputValid;
 }
  @SuppressWarnings("unused")
  protected void initOrUpdateForm(
      final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {
    // filter by tag
    if (formLayout.getFormComponent("tagLayout") == null) {
      tagFlc =
          FormLayoutContainer.createCustomFormLayout(
              "tagLayout", getTranslator(), this.velocity_root + "/filter-tags.html");
      formLayout.add(tagFlc);
      initTagFlc();
    } else {
      updateTagFlc();
    }

    // filter by type
    if (formLayout.getFormComponent("typeLayout") == null) {
      typeFlc =
          FormLayoutContainer.createCustomFormLayout(
              "typeLayout", getTranslator(), this.velocity_root + "/filter-types.html");
      formLayout.add(typeFlc);
      initOrUpdateTypeFlc(DEFAULT_TYPE_AMOUNT);
    } else {
      updateTypeFlc();
    }

    // filter by date
    if (formLayout.getFormComponent("dateLayout") == null) {
      final String page = this.velocity_root + "/filter_date.html";
      dateFlc = FormLayoutContainer.createCustomFormLayout("dateLayout", getTranslator(), page);
      formLayout.add(dateFlc);
      dateFlc.setLabel("filter.by.date", null);
      dateStart = uifactory.addDateChooser("filter.date.start", "", dateFlc);
      dateStart.addActionListener(this, FormEvent.ONCHANGE);
      dateEnd = uifactory.addDateChooser("filter.date.end", "", dateFlc);
      dateEnd.addActionListener(listener, FormEvent.ONCHANGE);
      dateStart.clearError();
      dateEnd.clearError();
    }

    if (filterSettings.getDateFilter().size() == 2) {
      dateStart.setDate(filterSettings.getDateFilter().get(0));
      dateEnd.setDate(filterSettings.getDateFilter().get(1));
    } else {
      dateStart.setDate(null);
      dateEnd.setDate(new Date());
    }

    // filter by fulltext
    final String searchText = filterSettings.getTextFilter();
    if (formLayout.getFormComponent("search") == null) {
      searchFld = uifactory.addTextElement("search", "filter.search", 20, searchText, formLayout);
      searchFld.addActionListener(listener, FormEvent.ONCHANGE);
    } else {
      searchFld.setValue(searchText);
    }

    // show filter list and save as new
    if (formLayout.getFormComponent("spacer") == null) {
      uifactory.addSpacerElement("spacer", formLayout, false);
    }

    // filter list
    initFilterList(formLayout);
    // filter save
    if (formLayout.getFormComponent("filterSaveLayout") == null) {
      filterFlc =
          FormLayoutContainer.createHorizontalFormLayout("filterSaveLayout", getTranslator());
      formLayout.add(filterFlc);
      filterFlc.setLabel("filter.save", null);
      filterName =
          uifactory.addTextElement(
              "filter.save.name", null, 30, filterSettings.getFilterName(), filterFlc);
      filterSave =
          uifactory.addFormLink(
              "filter.save.link", "filter.save.new", null, filterFlc, Link.BUTTON_XSMALL);
      filterDel =
          uifactory.addFormLink(
              "filter.del.link", "filter.del.link", null, filterFlc, Link.BUTTON_XSMALL);
    } else {
      filterName.setValue(filterSettings.getFilterName());
    }

    final boolean isExistingFilter = filterSettings.getFilterName() != null;
    toggleSaveUpdateFilterButtons(isExistingFilter);
  }