fc.web.forms
Class VFilledOnChoice

java.lang.Object
  extended by fc.web.forms.FormValidator
      extended by fc.web.forms.VConditional
          extended by fc.web.forms.VFilledOnChoice

public class VFilledOnChoice
extends VConditional

Validates that a certain radio or checkbox button selected (or not selected) implies that other fields in the form are also filled out. For example:

A radio button called "yes" is chosen by the user and this requires that a "yes_detail" field be filled out.


Constructor Summary
VFilledOnChoice(Form f, String name, String errorMessage, ChoiceGroup cg, String choiceValue, Field[] postFields)
           
VFilledOnChoice(Form f, String name, String errorMessage, ChoiceGroup cg, String choiceValue, List postFields)
           
 
Method Summary
 VFilledOnChoice anyFilled(boolean val)
          By default, this validator checks to see that all post-condition fields are filled.
 void onSelected(boolean val)
          Sets whether validation will occur if the choice is selected by the user or not.
 boolean postConditionMet(FormData fd, javax.servlet.http.HttpServletRequest req)
          Subclasses should implement this method to check that certain post conditions have been met.
 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.
 
Methods inherited from class fc.web.forms.VConditional
validate
 
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

VFilledOnChoice

public VFilledOnChoice(Form f,
                       String name,
                       String errorMessage,
                       ChoiceGroup cg,
                       String choiceValue,
                       List postFields)
Parameters:
f - the form
name - name for this validator
errorMessage - validation error message
choice - a pre condition choice group
val - the specific value of the pre condition choice group which will trigger the check to see that post condition fields are filled out
postFields - a non-empty list containing fields for the post condition

VFilledOnChoice

public VFilledOnChoice(Form f,
                       String name,
                       String errorMessage,
                       ChoiceGroup cg,
                       String choiceValue,
                       Field[] postFields)
Method Detail

anyFilled

public VFilledOnChoice anyFilled(boolean val)
By default, this validator checks to see that all post-condition fields are filled. However, if true is specified to this method, then validation will be successful if any specified field is filled.


preConditionMet

public boolean preConditionMet(FormData fd,
                               javax.servlet.http.HttpServletRequest req)
Description copied from class: VConditional
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.

Specified by:
preConditionMet in class VConditional
Returns:
true if the pre-conditions have been met, false otherwise

postConditionMet

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

Specified by:
postConditionMet in class VConditional
Returns:
true if the post-conditions have been met, false otherwise

onSelected

public void onSelected(boolean val)
Sets whether validation will occur if the choice is selected by the user or not. By default, validation occurs when the choice is selected by the user.

Parameters:
val - true to validate only when selected false otherwise.