/*
 * Copyright (C) 2017 the original author or authors.
 *
 * This file is part of jBB Application Project.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may obtain a copy of the License at
 *        http://www.apache.org/licenses/LICENSE-2.0
 */

package org.jbb.frontend.web.faq.logic;

import java.util.Set;
import javax.validation.ConstraintViolation;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;

@Component
public class FaqErrorsBindingMapper {

    public void map(Set<ConstraintViolation<?>> constraintViolations, BindingResult bindingResult) {
        for (ConstraintViolation violation : constraintViolations) {
            String propertyPath = violation.getPropertyPath().toString();
            propertyPath = propertyPath.replace("questions", "entries");
            bindingResult.rejectValue(propertyPath, "x", violation.getMessage());
        }
    }

}

/*
 * Copyright (C) 2017 the original author or authors.
 *
 * This file is part of jBB Application Project.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  You may obtain a copy of the License at
 *        http://www.apache.org/licenses/LICENSE-2.0
 */

package org.jbb.frontend.web.faq.logic;

import java.util.Set;
import javax.validation.ConstraintViolation;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindingResult;

@Component
public class FaqErrorsBindingMapper {

    public void map(Set<ConstraintViolation<?>> constraintViolations, BindingResult bindingResult) {
        for (ConstraintViolation violation : constraintViolations) {
            String propertyPath = violation.getPropertyPath().toString();
            propertyPath = propertyPath.replace("questions", "entries");
            bindingResult.rejectValue(propertyPath, violation.getMessage());
        }
    }

}

--- 
+++ 
@@ -22,7 +22,7 @@
         for (ConstraintViolation violation : constraintViolations) {
             String propertyPath = violation.getPropertyPath().toString();
             propertyPath = propertyPath.replace("questions", "entries");
-            bindingResult.rejectValue(propertyPath, violation.getMessage());
+            bindingResult.rejectValue(propertyPath, "x", violation.getMessage());
         }
     }
 
Fix error message for empty field in FAQ ACP form
