Field validation throwing an exception with SQLContainer

I have created a sublass of DefaultFieldFactory and assigned an instance of this class to a vaadin table via the setTableFieldFactory method. I have also assigned a SQLContainer instance to the table via setContainerDataSource. Below is a snippet of code from the createField of my TableFieldFactory. I have added a validator to a NAME field. It all seems to be set up correctly, however the InvalidValueException is
always
been thrown for the NAME field even when the corresponding textfield is assigned a non null value. Is there something more I need to do to ensure that the value as passed to the validate method (see below) matches what the user has entered in the corresponding Name field? I suppose there might be buffering issues but I understood that the “write through” property was set to true by default.

    field = super.createField(container, itemId, propertyId, uiContext);
    if (field instanceof AbstractTextField)
    {
        ((AbstractTextField) field).setNullRepresentation("");
        if (EditionVaadinContainer.NAME.equals((String) propertyId))
        {
        ((AbstractTextField) field).addValidator(new Validator() {

            @Override
            public void validate(Object value) throws InvalidValueException
            {
            String sValue = (String)value;
            
            if (StringUtils.trimToNull(sValue) == null)
            {
                throw new InvalidValueException("Edition Name must not be blank");
            }
            
            }
            
        });
        }

    }

Hello John,

I tried this one, though without SQLContainer. At least following seem to work for me. You said you extended from DefaultFieldFactory, can you try with TableFieldFactory instead? I can try also with SQLContainer if the previous does not help?

table.setTableFieldFactory(new TableFieldFactory () {
   @Override
   public Field<?> createField(Container container, Object itemId,
     Object propertyId, Component uiContext) {
    
    Field<?> field = new TextField((String) propertyId);
    if (propertyId.equals("Name")) {
     field.addValidator(new Validator() {

      @Override
      public void validate(Object value)
        throws InvalidValueException {
       String sValue = (String) value;

       if (StringUtils.trimToNull(sValue) == null) {
        throw new InvalidValueException(
          "Edition Name must not be blank");
       }

      }

     });
    }
    return field;
   }
  });