File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes JSF validation components !! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF validation components !!" Watch "JSF validation components !!" New topic
Author

JSF validation components !!

Arisson Leal
Greenhorn

Joined: Mar 14, 2008
Posts: 1
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

Joined: Jan 17, 2002
Posts: 495
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

Joined: Nov 26, 2007
Posts: 18
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

Joined: Mar 05, 2007
Posts: 107
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 ]

Sunil.V<br />SCJP2, SCWCD1.4, SCBCD1.3
Yohan Liyanage
Ranch Hand

Joined: Aug 17, 2007
Posts: 132

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.


Yohan Liyanage
http://blog.yohanliyanage.com
 
jQuery in Action, 2nd edition
 
subject: JSF validation components !!
 
Similar Threads
DynaValidatorForm not allowing insert.
Validation for included forms.
Component value Not getting updated - Strange Problem
JQuery In action - Data Access Options
Unclear on what's happening with validation