In wicket application I create my own Validator
which extends AbstractFormValidator
, and I have such code:
StringBuilder errorMessage = new StringBuilder();
...
ValidationError valError = new ValidationError();
valError.addKey("error.close.date.period");
valError.setMessage(errorMessage.substring(1));
component1.error(valError);
but it shows just error message from .properties
file. If I deleted addKey("error.close.date.period")
line, then it shows error from errorMessage
StringBuilder. I want to show both error.
Read the docs for ValidationError, setMessage does only provide a fallback if the key added using addKey is not found. You can't have both at the same time. What you need to use is variable substitution by using setVariable(s) and use the variable keys in your properties file with the error message provided under the key added by addKey, like you already did. Variable substitution works like ${variableKey} in the message.