Modifying the view
So far, validation is enabled. In fact, if you'd restart your application, validations would be performed. Try it, if you like.
However, when validation fails, we want to give the user some visual feedback. We'd like form controls corresponding to invalid fields to be marked red. If an assert condition fails, we'd want the controls involved to be marked, too. Even more important, we want to redisplay the inputs, the user made, when validation fails.
To get all this, you only have to use the custom tags, that come with the Calyxo Forms component. So, change the content of /WEB-INF/jsp/login.jspx as follows:
<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:base="http://calyxo.odysseus.de/jsp/base"
xmlns:forms="http://calyxo.odysseus.de/jsp/forms"
version="2.0">
<h3>Login, please...</h3>
<forms:form action="/login">
<table>
<tr>
<td align="right">User Id</td>
<td><forms:text name="user"/></td>
</tr>
<tr>
<td align="right">Password</td>
<td><forms:password name="password"/></td>
</tr>
</table>
<input type="submit" value="Submit"/>
</forms:form>
</jsp:root>
The last thing to do is adding error messages to our /WEB-INF/classes/messages.properties file:
login.user.unknown = User id {0} is unknown.
login.failed = Login failed.
# validation messages
login.user.invalid = Invalid user id.
login.userAndPasswordEqual = User id and password must not be equal.
You're done. Now, restart the application and see if form validation works.


