예제 #1
0
파일: DateField.java 프로젝트: hlship/tapx
  @Override
  protected void processSubmission(String elementName) {
    String value = request.getParameter(elementName);

    tracker.recordInput(this, value);

    updateClientTimeZone(elementName);

    Date parsedValue = null;

    try {
      if (InternalUtils.isNonBlank(value)) {
        // Regardless of the timeZone set on the DateFormat, the value is parsed in
        // the current default TimeZone. Use the calendar to adjust it out.

        Date inDefaultTimeZone = format.parse(value);

        parsedValue = convertDateToClientTimeZone(inDefaultTimeZone);
      }
    } catch (ParseException ex) {
      tracker.recordError(this, messages.format("tapx-date-value-not-parseable", value));
      return;
    }

    try {
      fieldValidationSupport.validate(parsedValue, resources, validate);

    } catch (ValidationException ex) {
      tracker.recordError(this, ex.getMessage());

      return;
    }

    if (min != null && parsedValue.before(min)) {
      tracker.recordError(this, messages.get("tapx-date-value-to-early"));
      return;
    }

    if (max != null && parsedValue.after(max)) {
      tracker.recordError(this, messages.get("tapx-date-value-too-late"));
      return;
    }

    this.value = parsedValue;
  }
예제 #2
0
  @SuppressWarnings({"unchecked"})
  @Override
  protected void processSubmission(String controlName) {
    String submittedValue = request.getParameter(controlName);

    tracker.recordInput(this, submittedValue);

    Object selectedValue = toValue(submittedValue);

    putPropertyNameIntoBeanValidationContext("value");

    try {
      fieldValidationSupport.validate(selectedValue, resources, validate);

      value = selectedValue;
    } catch (ValidationException ex) {
      tracker.recordError(this, ex.getMessage());
    }

    removePropertyNameFromBeanValidationContext();
  }