Directory

← Back

BeanGrid Add-on for Vaadin 8

@Autowired capable Grid<T> with annotation based configuration for Spring 4 and Vaadin 8

Author

Contributors

Rating

BeanGrid Add-on is Vaadin 8 compatible Add-on for @Autowiring pre-configured Vaadin Grid.

BeanGrid Add-on is a Spring @Configuration with efficient and lightweight integration of Grid via annotation based property configuration that supports editable and footer summarizable columns.

As Vaadin 8 allows defining type T for various components, this add-on makes the lives of Spring developers easier by providing a way to configure the Grid through annotations in T. The annotations are to be placed on the T's properties from which the pre configured and @Autowired Grid will pick them up.

Following annotations may be used with Grid's data type bean:

  • @GridColumn - for defining a column.
  • @EditableColumn - for making the column editable.
  • @SummarizableColumn - for automatically summarizing the column's all values.
  • @SummarizableColumnStaticText - for showing static text in the summary.

The add-on is designed to be as flexible and extensible as possible, where new editor components and field value providers can be integrated by implementing as bean:

  • BeanGridEditorComponentProvider
  • BeanGridValueProvider

Grid will look up the above implementations based on T's property types. For more advanced component and value providers the specialized

  • BeanGridValueConvertingEditorComponentProvider
  • BeanGridConvertingValueProvider

conversion capable providers can be implemented similarly. These types of providers allow converting between the property type in T and the type shown in the Grid's renderer or editor component.

BeanGrid supports automatically generated footer row summarizers where all the values within a column are summed up. Basic numeric summarizers are shipped with the add-on but new ones can be created for custom data types by implementing as bean the interface:

  • Summarizer

As the formatting of cell values, possible I18N integration etc are most likely needed in any real project, the BeanGrid supports translationKey resolution as well as external formatting configuration through interface:

  • GridConfigurationProvider

This interface can be implemented as bean which the BeanGrid will lookup every time it needs to resolve a translationKey or timestamp formatting or various other features from the host app.

See examples from Github project.

The annotations which are to be placed on T's properties have been externalized to a separate add-on: (BeanGrid Add-on for Vaadin 8 - Common Annotations). This is simply to support using these annotations without dependencies to Vaadin or Spring if necessary.

Using this add-on requires that Vaadin is Spring aware (through Vaadin Spring integration) as well as of course Spring 4.3 environment. Using Spring Boot is optional.

Usage of Maven or other dependency management tool is recommended as the add-on has a dependency to another add-on (BeanGrid Add-on for Vaadin 8 - Common Annotations) as well as various core libraries of Spring Framework and Spring <-> Vaadin Integration.

Sample code

public class Customer {

	@GridColumn(defaultOrder = 0, translationKey = "id")
	private long id;

	@GridColumn(defaultOrder = 1, translationKey = "firstName")
	@EditableColumn
	private String firstName;

	@GridColumn(defaultOrder = 2, translationKey = "lastName")
	private String lastName;

	@GridColumn(defaultOrder = 3, translationKey = "openInvoiceTotal", alignment = ColumnAlignment.RIGHT)
	@SummarizableColumn
	private BigDecimal openInvoiceTotal;

        ... 

       getters and setters
}
@Autowired
private Grid<Customer> testGrid;
@Configuration
@EnableBeanGrid
public class AppConfiguration {
  ...
@Component
public class TestGridConfigurationProvider implements GridConfigurationProvider {
 ...

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Initial release

Released
2017-03-28
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 8.0+
Browser
Browser Independent
Online