Editable table and error handling wont work

Hi,

Im using Vaadin 6.8.9 and I’m trying to get an editable table working. Without being an Vaadin Expert, I’ve so far managed to make alot of the desired functionality. But I can’t for the love of God make error handling work properly. When I committ the form (by pressing “Save” button), one would expect error messages to be visible. This works for the field “Name”, but not for fields inside the Table (see image attachment). What am I doing wrong?

I’m also attaching some extract of some main classes below.

Thank you in advance

======================================================
public class
CostForm
extends Form {
private Button saveButton;
private CostFormBean CostFormBean;

public CostForm(String description, 
        InitiativeGeneralInfo initiativeGeneralInfo, 
        List<InitiativeExternalReference> initiativeExternalReferenceList) {

    CostFormBean = new CostFormBean(initiativeGeneralInfo, initiativeExternalReferenceList);
    saveButton = new Button("Save", this, "save");

    setFormFieldFactory(new CostFieldFactory());
    setDataSource(CostFormBean);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setMargin(true);
    horizontalLayout.setSpacing(true);
    horizontalLayout.addComponent(saveButton);
    this.setFooter(horizontalLayout);
}

public void setDataSource(CostFormBean dataModel) {
    setItemDataSource(new BeanItem<CostFormBean>(dataModel));
    setVisibleItemProperties(new String[] { "name", "externalReferenceList"});
    setImmediate(true);
    setWriteThrough(false);
}

//This method is run before constructor! This is why we need to initialize layouts outside constructor!
@Override
protected void attachField(Object propertyId, Field field) {
    getLayout().addComponent(field);
}

public void save() {
    try {
        commit();
        System.out.println("Saving finished");
    } catch (EmptyValueException eve) {
        System.out.println("---EmptyValueException---");
    } catch (InvalidValueException ive) {
        System.out.println("-----Invalid values -------");
    }
}


}

public class
CostFormBean
{

private Integer id;
private String name;
private List<InitiativeExternalReference> externalReferenceList;


}

public class
CostFieldFactory
implements FormFieldFactory {

@Override
public Field createField(Item item, Object propertyId, Component uiContext) {
    final Form form = (Form) uiContext;
    String pid = (String) propertyId;

    if ("name".equals(pid)) {
        final TextField nameField = new TextField_IsEmptyMeansIsNull("Name");
        nameField.setRequired(true);
        nameField.setDescription("Initiative name");
        nameField.setImmediate(true);
        nameField.setRequiredError("Initiative name is missing");
        nameField.addValidator(new StringLengthValidator("Name can't be empty nor longer than 75 characters",1, 75, false));
        return nameField;
    }
    
    if ("externalReferenceList".equals(pid)) {
        Property property2 = item.getItemProperty("id");
        Integer initiativeId = (Integer)property2.getValue();
        
        final CostReferencesField costReferencesField = new CostReferencesField(initiativeId);
        costReferencesField.setCaption("References");
        return costReferencesField;
    }   
    return null;
}

}

public class
CostReferencesField
extends CustomField {

private Table referencesTable = new Table();
private BeanItemContainer<InitiativeExternalReference> referencesContainer = new BeanItemContainer<InitiativeExternalReference>(InitiativeExternalReference.class);
private final Button addNewReferenceLink;

public CostReferencesField(final Integer initiativeId) {
    
    VerticalLayout layout = new VerticalLayout();
    
    referencesTable.setContainerDataSource(referencesContainer);
    referencesTable.addGeneratedColumn("deleteButton", new MyDeleteButtonColumnGenerator());
    referencesTable.setColumnHeader("deleteButton", "");
    referencesTable.setWidth("400px");
    
    PrtService prtService = SpringCtx.get().getBean(PrtService.class);
    final List<ExternalSystem> allExternalSystem = prtService.getAllExternalSystem();
    setTableFieldFactory(allExternalSystem);
    referencesTable.setVisibleColumns(new Object[] {"name", "reference", "deleteButton"});
    referencesTable.setEditable(true);
    referencesTable.setColumnExpandRatio("name", 10);
    referencesTable.setColumnExpandRatio("reference", 10);
    referencesTable.setColumnExpandRatio("deleteButton", 1);
    
    addNewReferenceLink = new Button("<I>+ add Reference</I>"); 
    addNewReferenceLink.setHtmlContentAllowed(true);
    addNewReferenceLink.addStyleName(Button.STYLE_LINK);
    addNewReferenceLink.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            ExternalSystem defaultExternalSystemForNewEntries = allExternalSystem.get(0);
            Integer id = SpringFactory.getInstance().getVtsAppDB().insertInitiativeExternalReference(initiativeId, null, defaultExternalSystemForNewEntries == null ? "" : defaultExternalSystemForNewEntries.getName());
            
            for (Object itemId: referencesContainer.getItemIds()){
                referencesTable.addItem(itemId);

            }
            Object itemId = referencesContainer.addBean(new InitiativeExternalReference(id, initiativeId, null, defaultExternalSystemForNewEntries == null ? "" : defaultExternalSystemForNewEntries.getName(), ""));
            referencesTable.addItem(itemId);
            referencesTable.setPageLength(referencesContainer.size());
        }
    });
    
    layout.addComponent(referencesTable);
    layout.addComponent(addNewReferenceLink);
    setCompositionRoot(layout);
}

@Override
public Class<?> getType() {
    return  ArrayList.class;
}

@Override
public void setPropertyDataSource(Property newDataSource) {
    Object value = newDataSource.getValue();
    if (value instanceof List<?>) {
        @SuppressWarnings("unchecked")
        List<InitiativeExternalReference> beans = (List<InitiativeExternalReference>) value;
        referencesContainer.removeAllItems();
        referencesContainer.addAll(beans);
        referencesTable.setPageLength(beans.size());
    } else
        throw new ConversionException("Invalid type");

    super.setPropertyDataSource(newDataSource);
}

@Override
public Object getValue() {
    ArrayList<InitiativeExternalReference> beans = new ArrayList<InitiativeExternalReference>(); 
    for (Object itemId: referencesContainer.getItemIds())
        beans.add(referencesContainer.getItem(itemId).getBean());
    return beans;
}

@Override
public void setReadOnly(boolean readOnly) {
    referencesTable.setEditable(!readOnly);
    super.setReadOnly(readOnly);
}

public Table getReferencesTable() {
    return referencesTable;
}

public void setTableFieldFactory(List<ExternalSystem> allExternalSystem) {
    referencesTable.setTableFieldFactory(new CostReferencesTableFieldFactory(allExternalSystem));
}

private class MyDeleteButtonColumnGenerator implements Table.ColumnGenerator {
    @Override
    public Object generateCell(Table source, Object itemId, Object columnId) {
        Button button = MiscHelper.createDeleteReferenceLink((InitiativeExternalReference)itemId, source);
        return button;
    }
}

}

public class
CostReferencesTableFieldFactory
extends PRTDefaultFieldFactory {

List<ExternalSystem> allExternalSystem = null;

public CostReferencesTableFieldFactory(List<ExternalSystem> allExternalSystem) {
    super();
    this.allExternalSystem = allExternalSystem;
}

@Override
public Field createField(Container container, final Object itemId,
        Object propertyId, Component uiContext) {
    if ("name".equals(propertyId)) {
        CustomTableCombo select = new CustomTableCombo (new ComboBox());
        select.setData(itemId);  //rowId
        select.setRequired(true);
        select.setImmediate(true);
        select.addValidator(new StringLengthValidator("Please enter a valid strategic category",1, 999, false));
        select.setNullSelectionAllowed(false);
        for (ExternalSystem externalSystem : allExternalSystem) {
            select.addItem(externalSystem.getName());
        }
        
        addFieldToBeValidated(select);
        return select;
    }
    if ("reference".equals(propertyId)) {
        CustomTableTextField referenceTextField = new CustomTableTextField(new TextField_IsEmptyMeansIsNull());
        referenceTextField.setData(itemId); //rowId
        referenceTextField.setRequired(true);
        referenceTextField.setImmediate(true);
        referenceTextField.setNullSettingAllowed(false);
        referenceTextField.addValidator(new StringLengthValidator("Please enter a reference",1, 999, false));
        referenceTextField.setRequiredError("Reference is missing.");
        
        referenceTextField.addBlurListener(referenceTextField);
        addFieldToBeValidated(referenceTextField);
        return referenceTextField;
    }
    return null;
}

}

15505.png