Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ignore server side validation

 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi every body , I have a problem ,

I have a phone number field , that is being validated by JSF's validation.I have written one phone nunber validation .It is working fine .
I have one clear button also.If user dont want to put any value , (s)he may press the clear button.
But the problem is suppose user put some invalida phone number & press the clear button , the JSF is showing invalid phone number.But I dont want to do any type of validation , when user click the clear button.


Here is my JSF code :



Please help.

Thanks ,
S
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmmm....could you use 'immediate=true' for this situation?

-Cameron McKenzie
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply ,
could you please describe it more .

regards,
S
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18221
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you actually need to update the backing bean instead of just the displayed data, you can use JavaScript.

I think it goes like this:


I think you have to return false to make this a client-side only operation (cancels form submit). And the ID has to reflect the "true" ID of the PhoneField, not the JSF id. If in doubt, do a "view page source" on the rendered page to see what that is. It should be a composite of the control's ID plus the containing naming containers. If you see any generated names, put an ID on the container or you'll have problems, since generated names can vary unpredictably.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried what you told , but it is not working.

Thanks,
S
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks again Mr.Tim Holloway for your reply ,

But the problem is when user click the clear button , I have to clear the text field (phone field) .So I think for clear button event I have to post to the server & clear the text field.


regards,
S
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic