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 006 package fc.web.forms; 007 008 import javax.servlet.*; 009 import javax.servlet.http.*; 010 import java.io.*; 011 import java.util.*; 012 import java.util.regex.*; 013 014 import fc.jdbc.*; 015 import fc.io.*; 016 import fc.util.*; 017 018 /** 019 Validates that some condition/state for a group of fields 020 implies some other condition/state for another group of fields. 021 The pre/post conditions are both the result of {@VFilledGroup} 022 validators attached to the pre/post fields. 023 024 @author hursh jain 025 **/ 026 public abstract class VFilledOnFilled extends VConditional 027 { 028 VFilledGroup pre; 029 VFilledGroup 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 */ 037 public 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 048 public boolean preConditionMet(FormData fd, HttpServletRequest req) 049 { 050 return pre.validate(fd, req); 051 } 052 053 public boolean postConditionMet(FormData fd, HttpServletRequest req) 054 { 055 return post.validate(fd, req); 056 } 057 058 } //~class VFilledOnFilled 059