I have a login page where the page is submitted via a command button action attribute. The attribute points to a method that processes the page.
A username text box on the page has a custom validator that validates the username format which is an email. When an incorrect format is entered the validator does not throw a validator error in the PHASE PROCESS_VALIDATIONS phase. Instead it goes onto the PHASE INVOKE_APPLICATION phase where it throws an authentication error.
How do I get the page to throw the validation error?
Have you used immediate attribute by any chance in the command button?
as you said it is a custom validation, have you registered the custom validation in configuration file, could you post the login page code?
I did not use the immediate attribute and yes the validator is registered. When I debug I can actually see the application go throuhg each line of the validator but just doesn't throw the error it just goes on to the submit action. Here is the code:
I tried from my workspace, its perfectly working, something else is wrong. The code perfectly works.
is the control is going to validator method, if that is the case its very general that whenever an exception is thrown it shouldnt go to backingbean.
Suresh, did you setup the component exactly as in my jsp code above? If not, could you please try that?
The validation code is working, but the error message is still not seen. So, when I enter an invalid email, 'Email required message' is thrown, not the validation message.
I dont think I included this in my posts, but since the component uses the binding attribute and not the value attribute the following code needs to be added to the set accessor method of the component:
If not the h:message tag throws a standard error message when the field is empty.
I think you are making things complicated, Is there any specific reason of using binding attribute for the email?
I guess emailogval is a string variable how come you can use emailogval.getClientId(----) method.
without using a value attribute how can JSF set error messages wrt to that pirticular control.