fc.web.forms
Class VConditional

java.lang.Object
  extended by fc.web.forms.FormValidator
      extended by fc.web.forms.VConditional
Direct Known Subclasses:
VFilledOnChoice, VFilledOnFilled

public abstract class VConditional
extends FormValidator

Validates that certain conditions in one or more fields in the form require other conditions of some other fields in that form.

Since the pre/post conditions can be arbitrary, this class defines abstract methods called preConditionMet(fc.web.forms.FormData, javax.servlet.http.HttpServletRequest) and postConditionMet(fc.web.forms.FormData, javax.servlet.http.HttpServletRequest). If the pre condition is true, the post condition must also be true. Subclasses should implement both methods as appropriate.


Constructor Summary
VConditional(Form f, String name, String errorMessage)
           
 
Method Summary
abstract  boolean postConditionMet(FormData fd, javax.servlet.http.HttpServletRequest req)
          Subclasses should implement this method to check that certain post conditions have been met.
abstract  boolean preConditionMet(FormData fd, javax.servlet.http.HttpServletRequest req)
          Subclasses should implement this method to check that certain fields or pre-conditions have been met.
 boolean validate(FormData fd, javax.servlet.http.HttpServletRequest req)
          Returns the value returned by postConditionMet(fc.web.forms.FormData, javax.servlet.http.HttpServletRequest) if the pre conditions were met.
 
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

VConditional

public VConditional(Form f,
                    String name,
                    String errorMessage)
Method Detail

validate

public boolean validate(FormData fd,
                        javax.servlet.http.HttpServletRequest req)
Returns the value returned by postConditionMet(fc.web.forms.FormData, javax.servlet.http.HttpServletRequest) if the pre conditions were met. (preConditionMet(fc.web.forms.FormData, javax.servlet.http.HttpServletRequest) returned true). If the pre condition was not met, there is no need for further validation and this method will return true.

Specified by:
validate in class FormValidator
Returns:
true is validation succeeded, false otherwise

preConditionMet

public abstract boolean preConditionMet(FormData fd,
                                        javax.servlet.http.HttpServletRequest req)
Subclasses should implement this method to check that certain fields or pre-conditions have been met. Only gf these conditions have been met will there be a check to see that the post conditions are also true.

Returns:
true if the pre-conditions have been met, false otherwise

postConditionMet

public abstract boolean postConditionMet(FormData fd,
                                         javax.servlet.http.HttpServletRequest req)
Subclasses should implement this method to check that certain post conditions have been met. This method will only be called if the preConditionMet(fc.web.forms.FormData, javax.servlet.http.HttpServletRequest) method returns true.

Returns:
true if the post-conditions have been met, false otherwise