Greetings,
I have a xhtml page that displays a form with multiple rows on input that are editable. It can be described as something similar to what lies below:
Let us say that I have a students object. The students object contains a list of Student object.
Student
{
String fName;
String lName;
int age;
}
If the Student object has 3 students (John, Jim, James) It displays it as follows:
FNAME LNAME AGE
John Zorn 23
Jim Jones 25
James Mick 29
The values are displayed in an input field. There is a save button which saves data. If a user wants to change the data (say he wants to change John to Mike) - He has to enter the Mike in the inputTxt that displays John and press save. All this works fine.
Here is the problem iam encountering:
Let us say there is age validation and the user has to be above 18years old: If a user were to enter 'Mike' instead of 'John' and enters the age as '16' where is displays '23', the custom validator catches the error and displays the error message. Unfortunately, the other valid data entered by the user is lost. ie: when the page is redisplayed after a validation error - it displays 'John' instead of 'Mike'. I want the application to display Mike since it is a valid value.
However if the user leaves 'age' blank then
JSF throws a required validation error and the value 'Mike' is present as required.
Why does this difference exist between a custom validator and a built in validator ? Is there any way to force JSF to do the same thing with both the validator (ie. always display what the user has inputted and not what the bean value is) ?