Need help! I'm fighting validation!
brandonsimpson Apr 29, 2009 5:53 PMHere's the background of the problem: I have a complex data entry screen with about 20 input fields and 8 data tables. The data tables allow records to be added/removed via button presses. All of this worked great until I added Hibernate validation.
With validation enabled, if the user clicks the Save button and a validation error occurs, it breaks the functionality of the dynamic data tables. I've tried various combinations of immediate="true" and action/value change listeners but I just can't get normal behavior after a validation error occurs.
Either the add/remove buttons stop working completely, or the data tables "forget" any data entered by the user when an add/remove button is pressed.
With validation off, I can understand that probably my underlying model is being updated on each button press. With validation on and after a validation error, I'm guessing the underlying model is not updated, but also it seems that the data table rows aren't retaining any user input and revert back to whatever values they originally had. Is this a bug or JSF deficiency?
One other side effect is that after a validation error, any add/remove button press removes the validation error messages.
What I'd really like is for validation to only occur when the save button is pressed and for the rest of the user interactions to not be affected by validation. Is there any way to manually kick off the validation process in user code so that I could put this logic only in my save method? I'm already doing some validation there myself to highlight invalid values in the data table rows since this doesn't appear to be handled properly by JSF currently. I'm really really hoping I don't have to completely disable validation and do it all on my own but I have to make this screen work properly. Any ideas?
One other thing, several times when I've tried to post here, the post just seems to get eaten. I get the little dynamic graphic in the bottom left corner, but it stays there forever. The only thing that seems to help is to select "Let me type some plain text, not markup" before saving. Anyone know what's up with that?
With validation enabled, if the user clicks the Save button and a validation error occurs, it breaks the functionality of the dynamic data tables. I've tried various combinations of immediate="true" and action/value change listeners but I just can't get normal behavior after a validation error occurs.
Either the add/remove buttons stop working completely, or the data tables "forget" any data entered by the user when an add/remove button is pressed.
With validation off, I can understand that probably my underlying model is being updated on each button press. With validation on and after a validation error, I'm guessing the underlying model is not updated, but also it seems that the data table rows aren't retaining any user input and revert back to whatever values they originally had. Is this a bug or JSF deficiency?
One other side effect is that after a validation error, any add/remove button press removes the validation error messages.
What I'd really like is for validation to only occur when the save button is pressed and for the rest of the user interactions to not be affected by validation. Is there any way to manually kick off the validation process in user code so that I could put this logic only in my save method? I'm already doing some validation there myself to highlight invalid values in the data table rows since this doesn't appear to be handled properly by JSF currently. I'm really really hoping I don't have to completely disable validation and do it all on my own but I have to make this screen work properly. Any ideas?
One other thing, several times when I've tried to post here, the post just seems to get eaten. I get the little dynamic graphic in the bottom left corner, but it stays there forever. The only thing that seems to help is to select "Let me type some plain text, not markup" before saving. Anyone know what's up with that?