fc.web.forms
Class VFilledGroup

java.lang.Object
  extended by fc.web.forms.FormValidator
      extended by fc.web.forms.VFilledGroup

public final class VFilledGroup
extends FormValidator

Validates that a group of fields is filled by the user. By default, every field must be filled. However, optionally it can be specified that every field in the group is not filled (all empty), only 1 field is filled or 1 or more fields (greater than zero) are filled.


Constructor Summary
VFilledGroup(Form f, String name, String errorMessage, Field[] fields)
           
VFilledGroup(Form f, String name, String errorMessage, List fields)
           
 
Method Summary
 VFilledGroup allFilledOrEmpty()
          This is the default mode.
 VFilledGroup oneOrMoreFilled()
          Calling this method will result in requiring that one or more fields by filled (all the fields cannot be empty).
 VFilledGroup onlyOneEmpty()
          Calling this method will result in requiring that all fields must be filled except for any one empty field.
 VFilledGroup onlyOneFilled()
          Calling this method will result in requiring that all fields be empty except for exactly one filled field (any field).
 boolean validate(FormData fd, javax.servlet.http.HttpServletRequest req)
          Validates multiple fields together.
 
Methods inherited from class fc.web.forms.FormValidator
getErrorMessage, getName, setErrorMessage, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VFilledGroup

public VFilledGroup(Form f,
                    String name,
                    String errorMessage,
                    List fields)
Parameters:
fields - a non-empty list containting fields to be checked.

VFilledGroup

public VFilledGroup(Form f,
                    String name,
                    String errorMessage,
                    Field[] fields)
Parameters:
fields - a non-empty array containting fields to be checked.
Method Detail

onlyOneEmpty

public VFilledGroup onlyOneEmpty()
Calling this method will result in requiring that all fields must be filled except for any one empty field. Calling this method overrides any other methods that were called previously.


onlyOneFilled

public VFilledGroup onlyOneFilled()
Calling this method will result in requiring that all fields be empty except for exactly one filled field (any field). Calling this method overrides any other methods that were called previously.


oneOrMoreFilled

public VFilledGroup oneOrMoreFilled()
Calling this method will result in requiring that one or more fields by filled (all the fields cannot be empty). Calling this method overrides any other methods that were called previously.


allFilledOrEmpty

public VFilledGroup allFilledOrEmpty()
This is the default mode. Requires that all fields must be filled. Calling this method overrides any other methods that were called previously.


validate

public boolean validate(FormData fd,
                        javax.servlet.http.HttpServletRequest req)
Description copied from class: FormValidator
Validates multiple fields together. Note, implementations need not call the validator for each field if that field also has a field level validator (since each field is individually validated by the form). Implementations should validate multiple fields to see if they make sense when analysed as a whole.

Important notes: Typically, validation should be skipped in the following circumstances: