I know it's too late, but in case someone still need help. Here is the working solution.
Setting an error
is pretty straight forward. But it will be displayed to user, when he request Focus
on it. So to do the both thing on your own, User this code
.
firstName.setError("Enter FirstName");
firstName.requestFocus();