/**
   * @see FormSubmissionControllerAction#validateSubmission(FormEntryContext, HttpServletRequest)
   */
  @Override
  public Collection<FormSubmissionError> validateSubmission(
      FormEntryContext context, HttpServletRequest submission) {
    List<FormSubmissionError> ret = new ArrayList<FormSubmissionError>();

    try {
      if (dateWidget != null) {
        Date date = (Date) dateWidget.getValue(context, submission);
        if (timeWidget != null) {
          Date time = (Date) timeWidget.getValue(context, submission);
          date = HtmlFormEntryUtil.combineDateAndTime(date, time);
        }
        if (date == null) throw new Exception("htmlformentry.error.required");
        if (OpenmrsUtil.compare((Date) date, new Date()) > 0)
          throw new Exception("htmlformentry.error.cannotBeInFuture");
      }
    } catch (Exception ex) {
      ret.add(
          new FormSubmissionError(
              context.getFieldName(dateErrorWidget),
              Context.getMessageSourceService().getMessage(ex.getMessage())));
    }

    try {
      if (providerWidget != null) {
        Object value = providerWidget.getValue(context, submission);
        Person provider = (Person) convertValueToProvider(value);
        if (provider == null) throw new Exception("required");
      }
    } catch (Exception ex) {
      ret.add(
          new FormSubmissionError(
              context.getFieldName(providerErrorWidget),
              Context.getMessageSourceService().getMessage(ex.getMessage())));
    }

    try {
      if (locationWidget != null) {
        Object value = locationWidget.getValue(context, submission);
        Location location =
            (Location) HtmlFormEntryUtil.convertToType(value.toString().trim(), Location.class);
        if (location == null) throw new Exception("required");
      }
    } catch (Exception ex) {
      ret.add(
          new FormSubmissionError(
              context.getFieldName(locationErrorWidget),
              Context.getMessageSourceService().getMessage(ex.getMessage())));
    }
    try {
      if (encounterTypeWidget != null) {
        Object encounterType = encounterTypeWidget.getValue(context, submission);
        if (encounterType == null) throw new Exception("required");
      }
    } catch (Exception ex) {
      ret.add(
          new FormSubmissionError(
              context.getFieldName(encounterTypeErrorWidget),
              Context.getMessageSourceService().getMessage(ex.getMessage())));
    }
    return ret;
  }