Annotation Type GridColumn


  • @Retention(RUNTIME)
    @Target({METHOD,FIELD})
    @Documented
    public @interface GridColumn
    Provides the information necessary to auto-generate a Grid.Column and a field for editing values, based on annotated getter methods.

    Example:

    
     // Container backing object class
     public class User {
    
         private String username;
         private LocalDate dateOfBirth;
    
         @FieldBuilder.AbstractComponent(caption = "Username:")
         @FieldBuilder.AbstractTextField(maxLength = 16)
         @FieldBuilder.Binding(required = "Username is required")
         @GridColumn(caption = "Username", expandRatio = 3)
         public String getUsername() {
             return this.username;
         }
         public void setUsername(String username) {
             this.username = username;
         }
    
         @FieldBuilder.AbstractComponent(caption = "Date Of Birth:")
         @FieldBuilder.DateField
         @GridColumn(caption = "DOB", sortable = true)
         public LocalDate getDateOfBirth() {
             return this.dateOfBirth;
         }
         public void setDateOfBirth(LocalDate dateOfBirth) {
             this.dateOfBirth = dateOfBirth;
         }
     }
    
     // Build Grid with auto-generated columns
     Grid<User> grid = new GridColumnScanner(User.class).buildGrid();
     ...
     

    Some details regarding @GridColumn annotations:

    • Only non-void methods taking zero parameters are supported; @GridColumn annotations on other methods are ignored
    • Protected, package private, and private methods are supported.
    • @GridColumn annotations declared in super-types (including interfaces) are supported
    • If a method and the superclass or superinterface method it overrides are both annotated with @GridColumn, then the overridding method's annotation takes precedence.
    • If two methods with different names are annotated with @GridColumn for the same property name, then the declaration in the class which is a sub-type of the other wins (if the two classes are equal or not comparable, an exception is thrown). This allows subclasses to "override" which method supplies a given property.
    • Columns will be ordered first by order(), then by property name
    See Also:
    GridColumnScanner