Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Validation in JSF  RSS feed

 
Padma Priya
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am having Problem in solving a JSF Issue.

The scenerio is as below.

I have a form with a date field which makes use of the <hx:validateDateTimeRange/>. And I have a cancle button. I have set the immediate="true" for the cancle button.
So when i enter a wrong date and click on the save it gives me a validation error as expected. But when i click on the cancle button, the wrong date value which i am entering should not apprear in that field. But it is appearing which is not correct. I am setting the corresponding bean values to null but this not helping.

Could anyone help me out.

Thank you in advance!!!
 
Bajrang Asthana
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you not trying JavaScript. It is a good idea to do such tasks on client side.
 
Guy deLyonesse
Ranch Hand
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In JSF, a validatiion error short-circuits the JSF life cycle and goes immediately to the render response phase. If you want to clear the fields you may want to add a phase listener and put the code in there to reset your form.

bajrang asthana wrote:Why are you not trying JavaScript. It is a good idea to do such tasks on client side.


Not necessarily. JSF allows the code to be much cleaner and enable the JSF validation to handle things much more consistently and elegantly than is possible by trying to mix JSF and JavaScript.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!