Getters and setters in visual editor

I’ve been working with Vaadin composite components visual editor. All the fields are created private. So they are not accesible easily.

it’s easy with Eclipse to create getters and setters for each component, but as soon as the visual editor is entered getters and setters are erased.

I think it would be great the Visual editor not erase them. Better if the visual editor has properties like to create or not getters; even simpler: to change the scope of the fields to protected or public.

Aniceto

Hi,

I tried it and it doesn’t seem to remove the getters. For example, if there’s:

    @AutoGenerated
    private CheckBox checkBox_1;

I then make:

    public CheckBox getCheckBox_1() {
        return checkBox_1;
    }

For the sake of encapsulation, member variables should not be made public, at most protected. You can always make setters and getters to give wider access.

Only fields and methods tagged with @AutoGenerated should be removed - perhaps you have accidentally annotated your accessors. Otherwise, this is probably a bug, so a ticket with the sources of a visually composed class where it happens would be in order (assuming this is reproducible with the latest plug-in version).

For the rest, I agree with Marko in that public would certainly be too visible for the fields and maybe even for the accessors by default. Generating protected getters if the user hasn’t declared any might make sense - maybe this would be worth an enhancement request if there isn’t any.