I am using Play Framework 1.2.5 with Java. I have a login form. I am trying to validate the login form with an required check i.e. both the username and password are required. I did this code:
public static void welcome(@Required String txtUserName, @Required String txtPassword){
if(Validation.hasErrors()){
flash.error("Oops!!! Please enter your credentials!");
login();
}
render(txtUserName,txtPassword);
}
For displaying the messages, this is what I have in the heml page:
<td align="right">
#{if flash.error}
<p style="color: red;">
${ flash.error }
</p>
#{/if}
</td>
If any one or both of them is absent then I want to display specific messages i.e. If User Name is absent then the message should be "Please provide a User Name!!!". Presently, it is displaying a common message.
Please let me know how to achieve this.