Required table in a form

I am trying to make a required table in a form. i want the red * to appear next to the table’s caption in the form.

Here is my code:

[code]
protected void init(VaadinRequest request) {
final FormLayout layout = new FormLayout();
layout.setMargin(true);
setContent(layout);

    Table table = new Table("Caption goes here");
    table.setEditable(true);
    table.setRequired(true);
    table.setPageLength(3);
    layout.addComponent(table);
    TextField tf = new TextField("Caption goes here");
    tf.setRequired(true);
    layout.addComponent(tf);
}

[/code]I expected a red * to appear next to the caption, like it does for the TextField.

What is wrong and how do I fix it?

Environment: Java 7, Vaadin 7.4.5, Eclipse.

Curtis

This could be considered a bug and
reported
.

The reason seems to be that only field components can be required, but Table’s connector extends AbstractHasComponentsConnector instead of AbstractFieldConnector. Client-side classes like VCaption and many others check that for a component to be required, its connector must extend AbstractFieldConnector or its state AbstractFieldState.

There’s probably a good reason to extend AbstractHasComponentsConnector, so it could be hard to fix. Oh my, it looks that also TouchKit relies on the same assumption.

An easy workaround is to add an indicator with CSS. Add a “customrequired” style for the table and have something like:

.v-caption-customrequired .v-captiontext:after {
    color: red;
    content: "*";
}

I have logged the issue at:
https://dev.vaadin.com/ticket/17740