@Override protected void postValidate(ValidationErrors errors) { super.postValidate(errors); //remove errors from widget frames errors.getAll().removeIf(error -> !"dashboard$dashboardEditFieldGroup1".equals(error.component.getParent().getId())); List<Widget> dashboardWidgets = dashboardDs.getItem().getWidgets(); Map<String, Long> widgetsCount = dashboardWidgets.stream() .collect(Collectors.groupingBy(Widget::getWidgetId, Collectors.counting())); List<String> nonUniqueIds = widgetsCount.entrySet().stream() .filter(es -> es.getValue() > 1) .map(Map.Entry::getKey) .collect(toList()); if (nonUniqueIds.size() > 0) { errors.add(null, formatMessage("uniqueWidgetId", String.join(",", nonUniqueIds))); } }
@Override protected void postValidate(ValidationErrors errors) { super.postValidate(errors); WidgetTemplate widgetTemplate = widgetTemplateDs.getItem(); if (StringUtils.isEmpty(widgetTemplate.getWidgetModel())) { errors.add(widgetTypeLookup, getMessage("emptyWidgetError")); } } }
@Override protected void postValidate(ValidationErrors errors) { super.postValidate(errors); UserSubstitution substitution = getItem(); if (substitution.getStartDate() != null && substitution.getEndDate() != null) { if (substitution.getStartDate().getTime() > substitution.getEndDate().getTime()) { errors.add(startDateField, getMessage("dateOrderError")); } } } }
@Override protected void postValidate(ValidationErrors errors) { super.postValidate(errors); Widget widget = widgetDs.getItem(); if (widget.getDashboard() != null) { List<Widget> dashboardWidgets = widget.getDashboard().getWidgets(); long cnt = dashboardWidgets.stream() .filter(w -> !w.getId().equals(widget.getId()) && w.getWidgetId().equals(widget.getWidgetId())) .count(); if (cnt > 0) { errors.add(fieldGroup.getComponent("widgetId"), getMessage("uniqueWidgetId")); } } }