• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Form Not Retaining User Input after encountering a validation error.

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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) ?
 
You can't have everything. Where would you put it?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic