• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSF validation components !!

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ???
 
Ranch Hand
Posts: 495
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 132
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic