Search code examples
vaadinvaadin7

Vaadin declarative Grid caption via Annotations


While browsing through the source for Vaadin 7.6.1 i recognized, that there is no way of defining a column header based on an annotation, when using a BeanItemContainer<?>. Is there a way around this?

Imagine a simple CRUD application with 2 entity beans Foo and Bar:

public class Foo {
  private String interface_;
  private String uag;

  // Omitted getters / setters
  // ...
  }

public class Bar {
  private String forename;
  private String lastname;


  // Omitted getters / setters
  // ...
  }

When passing this beans to a BeanItemContainer<?> it creates magically deep inside Vaadin following column headers:

  • Interface_
  • Uag
  • Forename
  • Lastname

Is there a way around this and name generated properties after an Annotation for example? Is there a reason why this is not implemented? Just for curiosity.


Solution

  • The item properties in the BeanItemContainer are determined automatically by inspecting the getter and setter methods of the class.

    As far as I know there is no way to work with annotations for that case. You can define your getters/setters the way you like to control the property naming.