• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Required text field

 
Higgledy Smith
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always have validation in your backend bean before saving.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic