I am able to print the error messages in the console but unable to display the error messages in the UI.
This is the action code:
public static void welcome(User user){
validation.required("User Name",user.name).message("validation.message.em");
validation.required("Password",user.password).message("validation.message.em");
if(validation.hasErrors()) {
System.out.println("Validation errors found!!!");
for(Error error:validation.errors())
System.out.println(error.message());
params.flash(); // add http parameters to the flash scope
validation.keep(); // keep the errors for the next request
login();
}
This is the UI html code:
#{form @Application.welcome(), method:'get', id:'loginForm' }
<table>
<tr style="height: 100px">
<td colspan="2"><h1>
<b>Login</b>
</h1></td>
</tr>
<tr>
#{field 'user.name'}
<td> &{field.name} </td>
<td><input type="text" id="${field.id}" name="${field.name}" value="${field.value}" class="${field.errorClass}">
<span class="error">${field.error}</span>
#{/field}
</tr>
<tr>
#{field 'user.password'}
<td> &{field.name} </td>
<td><input type="password" id="${field.id}" name="${field.name}" value="${field.value}" class="${field.errorClass}">
<span class="error">${field.error}</span>
#{/field}
</tr>
<tr>
<td></td>
<td align="right"><input type="submit" value="Login"></td>
</tr>
</table>
#{/form}
This is the messages conf entry:
user.name=User Name
user.password=Password
validation.message.em=%s is required.
Please let me know what am I missing :(
Thanks,