Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF validation components !!

 
Arisson Leal
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have one form, where i add dynamically my fields. In this form i have two buttons one for add new fields and other for delete the fields.

My problem is, when i want to delete some fields i need the values to edit then in my managed bean in this moment i don't need the validadion provided by the JSF, but when i click in the button they try to validate. I just need the validation when i try to salve all form.

How can i do this ???
 
Abiodun Adisa
Ranch Hand
Posts: 495
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Arisson Leal:
Hi,

I have one form, where i add dynamically my fields. In this form i have two buttons one for add new fields and other for delete the fields.

My problem is, when i want to delete some fields i need the values to edit then in my managed bean in this moment i don't need the validadion provided by the JSF, but when i click in the button they try to validate. I just need the validation when i try to salve all form.

How can i do this ???



you can either create your own validation or use JSF validation, what do you want to validate for
 
Cindy Smith
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a similar problem. I have a "save" and a "submit" button on the same page. When the user clicks "save" I want to validate just the data type of the input fields. But when the user clicks "submit" I have some fields that are required. I don't think you can wire the JSF validations to distinguish between the two operations. I think we need to write our own validations to accomplish this. Any better ideas?
 
Sunil Vasudevan
Ranch Hand
Posts: 107
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a workaround:



In this case, the Last Name becomes required only if First Name has "Sunil" as submitted value. So you do acheive some amount of dynamic validations based on the input of your form values.

This is not the best solution. It is just one that worked for the project in which I was involved.

Initially the approach some guys came up with was to handle this in a PhaseListener. Based on the submitted value, toggle setRequired() on UI components. On a personal level, if I have to choose between two bad design approaches, the code sample provided is less evil than the PhaseListener approach.

If anyone else have any cleaner solutions, please let me know.
[ March 20, 2008: Message edited by: Sunil Vasudevan ]
 
Yohan Liyanage
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you wish to avoid validation, you may make use of immediate attribute of the commandButton.



This will allow the request generated by this command button to avoid the complete JSF Life-Cycle, which in turn avoids validation etc.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic