@AMahdy, @Tatu
thanks for the quick replay!
I will try to describe more, how the problem looks like. I use Vaadin validation on fields with binder - that all works really fine and there is no problem. After value change, validators are triggered and when value is wrong, fields is marked with red color, error description and the “!” sign. That’s perfect and that I want to keep.
What is more custom code, is behavior of submit button. After user press submit button - he will get fields marked with red and also he get notification with list of errors (it’s tray notification). List could look like this: “Please, fill username. Please, fill your age, Please, fill something…etc.”.
Besides that, I have implemented my own validator. Which compare current value and previous value. If the value is differend, user is notified with some logic, to decide what to do. For that, there is separatre window, which is called from validator. This also works fine but when user press submit button, it’s no point, to show him again the 10 windows,
so the question is, can I in validator somehow differentiate between whole form validation (after submit button) and between only one value change? To show him on submit press only list with errors and then, after he will modify the value trigger again the compare window? One solution, which I currently think about is to use session and put in session flag, that it’s from submit button and then remove it, afterwards.
Here is snippet of code from my CustomValidator:
@Override
public ValidationResult apply(Object value, ValueContext context) {
if(compare == null || acceptValue) {
return ValidationResult.ok();
}
T oldValue = (T) fieldFunction.apply(compare);
T currentValue = (T) value;
this.currentContext = context;
if(value != null && value.equals(oldValue)) {
return ValidationResult.ok();
}else{
String message = "Current value: " + currentValue + " - old value: " + oldValue;
compWindow = new CompareWindow(message, context.getComponent(), this);
UI.getCurrent().addWindow(compWindow);
return ValidationResult.error("There is missmatching");
}
}