001// Copyright (c) 2001 Hursh Jain (http://www.mollypages.org) 
002// The Molly framework is freely distributable under the terms of an
003// MIT-style license. For details, see the molly pages web site at:
004// http://www.mollypages.org/. Use, modify, have fun !
005
006package fc.web.forms;
007
008import javax.servlet.*;
009import javax.servlet.http.*;
010import java.io.*;
011import java.util.*;
012import java.util.regex.*;
013
014import fc.jdbc.*;
015import fc.io.*;
016import fc.util.*;
017
018/**
019Validates that some condition/state for a group of fields
020implies some other condition/state for another group of fields.
021The pre/post conditions are both the result of {@VFilledGroup}
022validators attached to the pre/post fields.
023
024@author hursh jain
025**/
026public abstract class VFilledOnFilled  extends VConditional
027{
028VFilledGroup pre;
029VFilledGroup post;
030
031/** 
032@param  name      name for this validator
033@param  errorMessage  validation error message
034@param  preValidator  a pre condition validator
035@param  postValidator a post condition validator
036*/
037public VFilledOnFilled(
038 Form f, String name, String errorMessage, 
039 VFilledGroup preValidator, VFilledGroup postValidator)
040  {
041  super(f, name, errorMessage);
042  Argcheck.istrue(preValidator != null, "specified pre validator was null");
043  Argcheck.istrue(postValidator != null, "specified post validator was null");
044  this.pre = preValidator;
045  this.post = postValidator;
046  }
047
048public boolean preConditionMet(FormData fd, HttpServletRequest req)
049  {
050  return pre.validate(fd, req);
051  }
052
053public boolean postConditionMet(FormData fd, HttpServletRequest req)
054  {
055  return post.validate(fd, req);
056  } 
057
058}          //~class VFilledOnFilled
059