You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "George Christman (JIRA)" <ji...@apache.org> on 2013/12/11 19:47:06 UTC

[jira] [Created] (TAP5-2258) AbstractValidator does not work with Date type

George Christman created TAP5-2258:
--------------------------------------

             Summary: AbstractValidator does not work with Date type
                 Key: TAP5-2258
                 URL: https://issues.apache.org/jira/browse/TAP5-2258
             Project: Tapestry 5
          Issue Type: Bug
          Components: tapestry-core
    Affects Versions: 5.4
            Reporter: George Christman


While trying to create a minimum date I noticed the AbstractValidator does not call the validate method when the datatype Date is used. See discussion on mailing list

http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Custom-Validator-for-Date-field-not-working-td5725189.html

Sample test code

AppModule.class

@SuppressWarnings("rawtypes")
    public static void
contributeFieldValidatorSource(MappedConfiguration<String, Validator>
configuration, JavaScriptSupport js) {
        configuration.add("minDate", new MinDate(js));
    }

Validator MinDate.class

public class MinDate extends AbstractValidator<String, Date> {

    public MinDate(JavaScriptSupport javaScriptSupport) {
        super(String.class, Date.class, "min-date", javaScriptSupport);
        System.out.println("min-date");
    }

    @Override
    public void validate(Field field, String constraintValue,
MessageFormatter formatter, Date value)
            throws ValidationException
    {
        System.out.println("ConstraintValue " + constraintValue);
        //throw new ValidationException(buildMessage(formatter, field,
constraintValue));
    }

    private String buildMessage(MessageFormatter formatter, Field field,
String constraintValue) {
        return formatter.format(constraintValue, field.getLabel());
    }

    @Override
    public void render(Field field, String c, MessageFormatter mf,
MarkupWriter writer, FormSupport fs) {
//        throw new UnsupportedOperationException("Not supported yet.");
//To change body of generated methods, choose Tools | Templates.
    }

}

tml

<t:DateField t:id="vacationAnniversary"  t:format="MM/dd/yyyy"
value="timeSheetEntity.vacationAnniversary"/>

TimeSheetEntity.class

@NonVisual
@Validate("minDate=test")
@Temporal(TemporalType.DATE)
private Date vacationAnniversary; 



--
This message was sent by Atlassian JIRA
(v6.1.4#6159)