I have a input text and a command button. The input text has some validations and when the user enters/updates an invallid text and clicks the command button, the message should appear that the value is invalid and the the data should revert back to the original text which was in the text box. How can it be done in JSF?
Actually, this isn't really a good idea. It's confusing to display an error message for a value that no longer exists on-screen.
An IDE is no substitute for an Intelligent Developer.
Joined: Dec 02, 2000
I agree that its confusing but that's the functionality the biz needs. On click of the button it should save the value if all the validations pass, but if the validations fail, the old value needs to be displayed on the screen
What you wanted to achieve is quite possible and it won't take much time. either way you have already defined your validation logic. You have something called <h:messages> which will help you display the error. If you want to reset the value to the original one can be done via js or java. It's like have a <f:ajax> in you commandButton and update the inputbox and <h:messages>.