Class 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 Details

    • 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
      postFields - a non-empty list containing fields for the post condition
      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
    • VFilledOnChoice

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

    • 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, jakarta.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, jakarta.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(FormData, 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.