you made getAcceptsNull as "false" so you'll never receive a null to validate...
On 7/30/07, César Augusto Mateus <[EMAIL PROTECTED]> wrote: > Hi all, > I did a Validator with the purpose of not to allow that a user entered a > date before of today. > That validation work fine, but not yet i can to do that this validator is > obligatory, because when i enter a null value, the validator was not call. > My Validator code here, thanks > > package co.org.amv.rupm.tapestry.models; > > import java.util.Date; > > import org.apache.tapestry.IMarkupWriter; > import org.apache.tapestry.IRequestCycle; > import org.apache.tapestry.form.FormComponentContributorContext; > import org.apache.tapestry.form.IFormComponent; > import org.apache.tapestry.form.ValidationMessages; > import org.apache.tapestry.form.validator.BaseValidator; > import org.apache.tapestry.form.validator.Validator; > import org.apache.tapestry.valid.ValidationConstants; > import org.apache.tapestry.valid.ValidatorException; > > public class ValidatorFecAntesHoyRequired extends BaseValidator implements > Validator { > > > public void validate( > IFormComponent field, ValidationMessages messages, Object > object) > throws ValidatorException { > Date fecha = (Date) object; > // IF THE USER ENTER A NULL VALUE, NEVER PAINT THIS > System.out.println("----"+fecha); > // THEN NEVER THROW THIS EXCEPTION > if( fecha == null ){ > throw new ValidatorException( field.getDisplayName() + ": Debe > ingresar un valor", null ); > } > Date hoy = new Date(); > if( fecha.after( hoy ) ){ > throw new ValidatorException( > field.getDisplayName() + ": La fecha no puede ser > posterior a la fecha actual", null ); > } > } > > public boolean getAcceptsNull() { > return false; > } > > public boolean isRequired() { > return true; > } > > public void renderContribution( > IMarkupWriter arg0, IRequestCycle cycle, > FormComponentContributorContext context, IFormComponent field) { > } > > } > > Thanks for your help, Which is my error??? > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]