How do I display on a view jsp validation error message that occurs as a result of @AssertTrue
annotation? It isn't tied to a specific field, but I am using it to validate a combination of fields. If I use <form:errors path="*"/>
that will display all the errors for that form?
From what I have tested it is important HOW you name your test function. And you should name it properly.
You do not need field, getter or setter but your function HAVE TO start with 'is*' statement.
fe.
@AssertTrue
public boolean isConditionTrue() {
...
...
}
or
@AssertTrue
public boolean isSomethingElseOk() {
...
...
}
Though, you need a field and getter/setter if you need to use a error form with path, like:
<form:errors path="someFieldToDisplay" />
But i think this is quite obvious.
This might be helpful as well: lack of error messages.
But if you use schema without version tag, it uses the newest version by default.
Declaring a boolean property is what seems to work for this. So if there is:
@AssertTrue
public boolean isConditionTrue() {
...
...
}
then declaring a property like:
private boolean conditionTrue;
works.
You should name your property like this:
@AssertTrue(message = "....")
private boolean conditionTrue; //***NOT isConditionTrue***
public boolean isConditionTrue() {
return conditionTrue;
}
public void setConditionTrue(boolean conditionTrue) {
this.conditionTrue= conditionTrue;
}
<form:errors path="*"/> or
<form:errors path="conditionTrue"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With