aspose file tools*
The moose likes JSF and the fly likes Required text field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Required text field" Watch "Required text field" New topic
Author

Required text field

Higgledy Smith
Ranch Hand

Joined: Mar 07, 2006
Posts: 192

In a form with two text fields, either one is required. For instance, if the Zip Code is supplied, then the address is not required. But if the Zip Code is not supplied then the address is required.

In my code below, I need the company name -OR- the DUNS Number.

How do I code this logic? Here is my form:




Thank you.
higgledy


nitin pokhriyal
Ranch Hand

Joined: May 19, 2005
Posts: 263
You can always have validation in your backend bean before saving.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15661
    
  15

This is a good use for a validator, although none of the stock JSF core validators do this. I think that the MyFaces Extensions Validators may include something that will do the trick, though.

I wrote my own for passwords, where you have 2 password inputs and only if they both match will the action be considered valid.

You CAN do this kind of checking in the action processor, but it's somewhat cleaner not to have to.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Required text field
 
Similar Threads
fields not getting updated.
To Refresh the Dynamic data to the JSF Page automatically
Multiple file upload not working
Populate a SelectOneMenu and others
HOW TO REFRESH THE FULL PAGE USING JSF ICE FACES AND TO GET THE UPDATED RECORDS INTO PAGE