Pergunta

I tried to add some validations to DateTextField as follows:

      IFormValidator validator = new AbstractFormValidator() {
        public FormComponent<?>[] getDependentFormComponents() {
            return new FormComponent[] { dateTextField };
        }

        public void validate(Form<?> form) {
            Date date = (Date) dateTextField.getConvertedInput();

            if(date == null){
                error(getDependentFormComponents()[0],"Date of Collection is empty.");
            }
            else{
                if (date.before(getTodayDate(Boolean.TRUE))){
                    error(getDependentFormComponents()[0],"The range of the Date of Collection is invalid.");
                }
            }
        }
    };

    form.add(validator);

The validations are working absolutely fine but the output of error message appeared as below:

  Could not locate error message for component: CreatePrintingJob$3@form:dateOfCollection and error: [ValidationError message=[null], keys=[Date of Collection is empty., CreatePrintingJob$4], variables=[[label0=dateOfCollection],[name0=dateOfCollection],[input0=]]]. Tried keys: dateOfCollection.Date of Collection is empty., Date of Collection is empty., dateOfCollection.CreatePrintingJob$4, CreatePrintingJob$4.

Why could not the error message be located?

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top