Example usage for org.apache.wicket.validation.validator DateValidator maximum

List of usage examples for org.apache.wicket.validation.validator DateValidator maximum

Introduction

In this page you can find the example usage for org.apache.wicket.validation.validator DateValidator maximum.

Prototype

public static DateValidator maximum(Date maximum) 

Source Link

Usage

From source file:au.org.theark.study.web.component.address.form.DetailForm.java

License:Open Source License

@Override
protected void attachValidators() {

    addressLineOneTxtFld.add(StringValidator.maximumLength(255));

    sourceTxtFld.add(StringValidator.maximumLength(255));

    streetAddressTxtFld.setRequired(true).setLabel(new StringResourceModel(
            "address.streetAddress.RequiredValidator", this, new Model<String>("Street Address")));

    streetAddressTxtFld.add(LengthBetweenValidator.maximumLength(255));

    cityTxtFld.setRequired(true).setLabel(
            new StringResourceModel("address.city.RequiredValidator", this, new Model<String>("City")));

    postCodeTxtFld.setRequired(true).setLabel(new StringResourceModel("address.postCode.RequiredValidator",
            this, new Model<String>("Post Code")));
    // TODO User Centric ones for Max and Min
    postCodeTxtFld.add(LengthBetweenValidator.maximumLength(10));
    postCodeTxtFld.add(LengthBetweenValidator.minimumLength(4));

    dateReceivedDp.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("address.dateReceived.DateValidator.maximum", this, null));

    addressTypeChoice.setRequired(true).setLabel(new StringResourceModel(
            "address.addressType.RequiredValidator", this, new Model<String>("Address Type")));
    addressStatusChoice.setRequired(true).setLabel(new StringResourceModel(
            "address.addressStatus.RequiredValidator", this, new Model<String>("Address Status")));
    stateChoice.setRequired(true).setLabel(
            new StringResourceModel("address.state.RequiredValidator", this, new Model<String>("State")));
}

From source file:au.org.theark.study.web.component.consent.form.DetailForm.java

License:Open Source License

@Override
protected void attachValidators() {
    commentTxtArea//from   w  w w .  j  a v  a2  s . c om
            .add(StringValidator
                    .maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_COMMENTS_MAX_LENGTH_500))
            .setLabel(new StringResourceModel("consent.comments.StringValidator.maximum", this, null));
    consentedBy.add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_MAX_LENGTH_100))
            .setLabel(new StringResourceModel("consent.consentedBy.StringValidator.maximum", this, null));
    studyComponentChoice.setRequired(true)
            .setLabel(new StringResourceModel("study.component.choice.required", this, null));
    consentStatusChoice.setRequired(true)
            .setLabel(new StringResourceModel("consent.status.required", this, null));
    consentTypeChoice.setRequired(true).setLabel(new StringResourceModel("consent.type.required", this, null));
    studyComponentStatusChoice.setRequired(true)
            .setLabel(new StringResourceModel("studyComponent.status.required", this, null));
    consentedDatePicker.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("consent.consentDate.DateValidator.maximum", this, null));
    consentCompletedDtf.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("consent.completedDate.DateValidator.maximum", this, null));
    consentRequestedDtf.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("consent.requestedDate.DateValidator.maximum", this, null));
    consentReceivedDtf.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("consent.receivedDate.DateValidator.maximum", this, null));

    consentCompletedDtf.setRequired(true)
            .setLabel(new StringResourceModel("consent.completedDate.choice.required", this, null));
    consentRequestedDtf.setRequired(true)
            .setLabel(new StringResourceModel("consent.requestedDate.choice.required", this, null));
    consentReceivedDtf.setRequired(true)
            .setLabel(new StringResourceModel("consent.receivedDate.choice.required", this, null));
}

From source file:au.org.theark.study.web.component.contact.form.AddressDetailForm.java

License:Open Source License

@Override
protected void attachValidators() {

    addressLineOneTxtFld.add(StringValidator.maximumLength(255));
    sourceTxtFld.add(StringValidator.maximumLength(255));
    streetAddressTxtFld.setRequired(true).setLabel(new StringResourceModel(
            "address.streetAddress.RequiredValidator", this, new Model<String>("Street Address")));
    streetAddressTxtFld.add(LengthBetweenValidator.maximumLength(255));
    cityTxtFld.setRequired(true).setLabel(
            new StringResourceModel("address.city.RequiredValidator", this, new Model<String>("City")));
    postCodeTxtFld.setRequired(true).setLabel(new StringResourceModel("address.postCode.RequiredValidator",
            this, new Model<String>("Post Code")));
    // TODO User Centric ones for Max and Min
    postCodeTxtFld.add(LengthBetweenValidator.maximumLength(10));
    postCodeTxtFld.add(LengthBetweenValidator.minimumLength(4));
    dateReceivedDp.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("address.dateReceived.DateValidator.maximum", this, null));
    addressTypeChoice.setRequired(true).setLabel(new StringResourceModel(
            "address.addressType.RequiredValidator", this, new Model<String>("Address Type")));
    addressStatusChoice.setRequired(true).setLabel(new StringResourceModel(
            "address.addressStatus.RequiredValidator", this, new Model<String>("Address Status")));
    stateChoice.setRequired(true).setLabel(
            new StringResourceModel("address.state.RequiredValidator", this, new Model<String>("State")));
    //Bug fix Ark-1611
    sourceTxtFld.add(StringValidator//www.  ja  v  a2s .  c  o  m
            .maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));
    cityTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    commentsTxtArea.add(
            StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_COMMENTS_MAX_LENGTH_500));
}

From source file:au.org.theark.study.web.component.contact.form.PhoneDetailForm.java

License:Open Source License

@Override
protected void attachValidators() {
    areaCodeTxtFld.add(StringValidator.maximumLength(10));
    phoneTypeChoice.setRequired(true).setLabel(
            (new StringResourceModel("phone.phoneType.required", this, new Model<String>("Phone Type"))));
    phoneNumberTxtFld.setRequired(true).setLabel(
            (new StringResourceModel("phone.phoneNumber.required", this, new Model<String>("Phone Number"))));
    phoneStatusChoice.setRequired(true).setLabel(
            (new StringResourceModel("phone.phoneStatus.required", this, new Model<String>("Phone Status"))));
    phoneNumberTxtFld.add(StringValidator.maximumLength(20));
    dateReceivedDp.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("phone.dateReceived.DateValidator.maximum", this, null));
    source.add(/*from   w ww .ja va  2  s . c  o  m*/
            StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_COMMENTS_MAX_LENGTH_500));
    commentsTxtArea.add(
            StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_COMMENTS_MAX_LENGTH_500));

}

From source file:au.org.theark.study.web.component.managestudy.form.DetailForm.java

License:Open Source License

@Override
protected void attachValidators() {
    studyNameTxtFld.setRequired(true).setLabel(
            new StringResourceModel("error.study.name.required", this, new Model<String>("Study Name")));
    // TODO Have to stop the validator posting the content with the error message
    studyDescriptionTxtArea.add(StringValidator.lengthBetween(1, 255)).setLabel(new StringResourceModel(
            "study.description.length.exceeded", this, new Model<String>("Study Synopsis")));
    studyStatusDpChoices.setRequired(true).setLabel(
            new StringResourceModel("error.study.status.required", this, new Model<String>("Status")));

    // Max dateOfApplicationDp can be only today
    dateOfApplicationDp.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("error.study.doa.max.range", this, null));

    // TODO: Write CustomValidator to handle numeric validation
    // Estimated Year of completion a numeric year field, greater than dateOfApplicationDp
    // estYearOfCompletionTxtFld.add(new PatternValidator("^\\d{4}$")).setLabel(new StringResourceModel("error.study.yearOfCompletion", this, new
    // Model<String>("Estimated Year of Completion")));

    chiefInvestigatorTxtFld.setRequired(true).setLabel(
            new StringResourceModel("error.study.chief", this, new Model<String>("Chief Investigator")));
    chiefInvestigatorTxtFld.add(StringValidator.lengthBetween(3, 50));

    coInvestigatorTxtFld.add(StringValidator.lengthBetween(3, 50)).setLabel(
            new StringResourceModel("error.study.co.investigator", this, new Model<String>("Co Investigator")));
    // selectedApplicationsLmc.setRequired(true).setLabel( new StringResourceModel("error.study.selected.app", this, null));
    subjectUidStartTxtFld.add(new RangeValidator<Integer>(1, Integer.MAX_VALUE))
            .setLabel(new StringResourceModel("error.study.subject.key.prefix", this, null));
    // file image validator, checking size, type etc
    fileUploadField.add(new StudyLogoValidator());

    // Make parentStudy drop-down required for Study Administrators and study in context
    Subject currentUser = SecurityUtils.getSubject();
    Long studyId = (Long) SecurityUtils.getSubject().getSession()
            .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID);
    if (studyId != null) {
        try {//ww w .j  a  v  a 2 s  .  co m
            if (!iArkCommonService.isSuperAdministrator(currentUser.getPrincipal().toString())) {
                parentStudyDdc.setRequired(true).setLabel(new StringResourceModel("study.parentStudy.required",
                        this, new Model<String>("Parent Study")));
            }
        } catch (EntityNotFoundException e) {
            log.error(e.getMessage());
        }
    }

}

From source file:au.org.theark.study.web.component.phone.form.DetailForm.java

License:Open Source License

@Override
protected void attachValidators() {
    areaCodeTxtFld.add(StringValidator.maximumLength(10));
    phoneTypeChoice.setRequired(true).setLabel(
            (new StringResourceModel("phone.phoneType.required", this, new Model<String>("Phone Type"))));
    phoneNumberTxtFld.setRequired(true).setLabel(
            (new StringResourceModel("phone.phoneNumber.required", this, new Model<String>("Phone Number"))));
    phoneStatusChoice.setRequired(true).setLabel(
            (new StringResourceModel("phone.phoneStatus.required", this, new Model<String>("Phone Status"))));
    phoneNumberTxtFld.add(StringValidator.maximumLength(20));
    dateReceivedDp.add(DateValidator.maximum(new Date()))
            .setLabel(new StringResourceModel("phone.dateReceived.DateValidator.maximum", this, null));
}

From source file:au.org.theark.study.web.component.subject.form.DetailForm.java

License:Open Source License

@Override
protected void attachValidators() {
    subjectUIDTxtFld.setRequired(true).setLabel(new StringResourceModel("subject.uid.required", this, null));
    dateOfBirthTxtFld.setLabel(//from w w w.  j  a  v a  2 s  . c om
            new StringResourceModel("linkSubjectStudy.person.dateOfBirth.DateValidator.maximum", this, null));
    subjectStatusDdc.setRequired(true).setLabel(new StringResourceModel("subject.status.required", this, null));
    consentDateTxtFld.setLabel(new StringResourceModel("consentDate", this, null));
    consentDateTxtFld.add(DateValidator.maximum(new Date())).setLabel(
            new StringResourceModel("linkSubjectStudy.consentDate.DateValidator.maximum", this, null));
    dateLastKnownAliveTxtFld.add(DateValidator.maximum(new Date())).setLabel(new StringResourceModel(
            "linkSubjectStudy.person.dateLastKnownAlive.DateValidator.maximum", this, null));
    preferredEmailTxtFld.add(EmailAddressValidator.getInstance());
    otherEmailTxtFld.add(EmailAddressValidator.getInstance());
    consentStatusChoice.setRequired(true)
            .setLabel(new StringResourceModel("consentStatus.required", this, null));
    //Add new validators on 2016-05-19(Ark-1603).
    firstNameTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    middleNameTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    lastNameTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    previousLastNameTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    preferredNameTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    causeOfDeathTxtFld.add(StringValidator
            .maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_DESCRIPTIVE_MAX_LENGTH_255));
    commentTxtAreaFld.add(
            StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_COMMENTS_MAX_LENGTH_500));
    heardAboutStudyTxtFld.add(
            StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_COMMENTS_MAX_LENGTH_500));
    preferredEmailTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
    otherEmailTxtFld
            .add(StringValidator.maximumLength(au.org.theark.core.Constants.GENERAL_FIELD_NAME_MAX_LENGTH_50));
}

From source file:org.obiba.onyx.wicket.data.validation.converter.RangeValidatorNodeConverter.java

License:Open Source License

public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    DataType type = (DataType) context.get("validatorDataType");

    String minimumStr = null;// w  w  w . j  a v  a 2  s. co m
    String maximumStr = null;
    while (reader.hasMoreChildren()) {
        reader.moveDown();
        String nodeName = reader.getNodeName();
        if (nodeName.equalsIgnoreCase("minimum")) {
            minimumStr = reader.getValue();
        } else if (nodeName.equalsIgnoreCase("maximum")) {
            maximumStr = reader.getValue();
        }
        reader.moveUp();
    }

    IValidator validator = null;
    switch (type) {
    case INTEGER: {
        Long minimum = minimumStr == null ? null : Long.valueOf(minimumStr);
        Long maximum = maximumStr == null ? null : Long.valueOf(maximumStr);
        if (minimum != null && maximum != null) {
            validator = new RangeValidator(minimum, maximum);
        } else if (minimum != null) {
            validator = new MinimumValidator(minimum);
        } else if (maximum != null) {
            validator = new MaximumValidator(maximum);
        }
        break;
    }
    case DECIMAL: {
        Double minimum = minimumStr == null ? null : Double.valueOf(minimumStr);
        Double maximum = maximumStr == null ? null : Double.valueOf(maximumStr);
        if (minimum != null && maximum != null) {
            validator = new RangeValidator(minimum, maximum);
        } else if (minimum != null) {
            validator = new MinimumValidator(minimum);
        } else if (maximum != null) {
            validator = new MaximumValidator(maximum);
        }
        break;
    }
    case DATE: {
        Date minimum = minimumStr == null ? null : parseDate(minimumStr);
        Date maximum = maximumStr == null ? null : parseDate(maximumStr);
        if (minimum != null && maximum != null) {
            validator = DateValidator.range(minimum, maximum);
        } else if (minimum != null) {
            validator = DateValidator.minimum(minimum);
        } else if (maximum != null) {
            validator = DateValidator.maximum(maximum);
        }
        break;
    }
    case TEXT: {
        Integer minimum = minimumStr == null ? null : Integer.valueOf(minimumStr);
        Integer maximum = maximumStr == null ? null : Integer.valueOf(maximumStr);
        if (minimum != null && maximum != null) {
            validator = StringValidator.lengthBetween(minimum, maximum);
        } else if (minimum != null) {
            validator = StringValidator.minimumLength(minimum);
        } else if (maximum != null) {
            validator = StringValidator.maximumLength(maximum);
        }
        break;
    }
    default:
        throw new ConversionException("Invalid type for rangeValidator node: '" + type + "'");
    }
    if (validator == null) {
        throw new ConversionException("Invalid rangeValidator node");
    }
    return validator;
}