Directory

← Back

Crud UI Add-on

Generate CRUD UIs for your entities/beans/POJOs at runtime

Author

Rating

Popularity

10900+

Crud UI Add-on provides an API to automatically generate CRUD-like UIs for any Java Bean at runtime.

The API is defined through 4 interfaces:

CrudComponent: A Vaadin Component that can be added to any ComponentContainer. This is the actual CRUD final users will see in the browser.

CrudListener: Encapsulates the CRUD operations. You can implement this interface to delegate CRUD operations to your back-end.

CrudLayout: Encapsulates layout-related behavior.

CrudFormFactory: Builds the forms required by the CRUD UI.

The add-on includes several implementations of these interfaces.

Basic usage

Say, you have the following domain/entity/Java Bean class:

public class User {

    @NotNull // Validation API is required! Add it as a dependency on your project
    private Long id;

    @NotNull
    private String name;

    private Date birthDate;

    @Email
    private String email;

    @NotNull
    private String password;

    ... getters & setters ...
}

 

You can create a new CRUD component and add it into any Vaadin layout as follows:

GridCrud<User> crud = new GridCrud<>(User.class);
layout.addComponent(crud);

 

You can enable Java Bean Validation as follows:

crud.getCrudFormFactory().setUseBeanValidation(true);

 

Use lambda expressions or method references to delegate CRUD operations to your backend:

crud.setFindAllOperation(() -> backend.findAll());
crud.setAddOperation(backend::add);
crud.setUpdateOperation(backend::update);
crud.setDeleteOperation(backend::delete);

 

Advanced usage

As an alternative to method references and lambda expressions, you can implement a CrudListener to delegate CRUD operations to your backend:

crud.setCrudListener(new CrudListener<User>() {
    @Override
    public Collection<User> findAll() {
        return backend.findAllUsers();
    }
    @Override
    public User add(User user) {
        return backend.add(user);
    }

    @Override
    public User update(User user) {
        return backend.update(user);
    }

    @Override
    public void delete(User user) {
        backend.remove(user);
    }
});

 

Use a different CrudLayout implementation:

GridCrud<User> crud = new GridCrud<>(User.class, new HorizontalSplitCrudLayout());

 

Set a custom CrudFormFactory:

CustomCrudFormFactory<User> formFactory = new CustomCrudFormFactory<>(User.class);
crud.setCrudFormFactory(formFactory);

 

Configure form fields visibility:

formFactory.setVisibleProperties(CrudOperation.READ, "name", "birthDate", "email", "groups", "mainGroup", "active");
formFactory.setVisibleProperties(CrudOperation.ADD, "name", "birthDate", "email", "password", "groups", "mainGroup", "active");
formFactory.setVisibleProperties(CrudOperation.UPDATE, "name", "birthDate", "email", "groups", "mainGroup", "active");
formFactory.setVisibleProperties(CrudOperation.DELETE, "name", "email");

 

Use nested properties in GridCrud instances:

crud.getGrid().addColumn(user -> user.getMainGroup().getName()).setHeader("Main group").setKey("key");

 

Configure the type of an input field:

formFactory.setFieldType("password", PasswordField.class);

 

Customize fields after their creation:

formFactory.setFieldCreationListener("birthDate", field -> ... your own logic here ...);

 

Define a FieldProvider to manually create a field:

formFactory.setFieldProvider("groups", user -> {
    CheckboxGroup<Group> checkboxes = new CheckboxGroup<>();
    checkboxes.setItems(groups);
    checkboxes.setItemLabelGenerator(Group::getName);
    return checkboxes;
});

 

Or use one of the included FieldProvider implementations:

formFactory.setFieldProvider("groups",
        new CheckBoxGroupProvider<>("Groups", GroupRepository.findAll(), Group::getName));

 

Set a Converter:

formFactory.setConverter("salary", new Converter<String, BigDecimal>() {
    @Override
    public Result<BigDecimal> convertToModel(String value, ValueContext valueContext) {
        return Result.ok(new BigDecimal(value)); // error handling omitted
    }

    @Override
    public String convertToPresentation(BigDecimal value, ValueContext valueContext) {
        return value.toPlainString();
    }
});

Customize captions:

formFactory.setButtonCaption(CrudOperation.ADD, "Add new user");
crud.setRowCountCaption("%d user(s) found");

 

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

Fixes #51 - Prevent form from closing if add/edit operation fails with exception. Scroll to added/updated item in GridCrud. Updated to Java 21 and Vaadin 24.4.4

Released
2024-07-02
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 24+
Vaadin 7.5+ in 1.2
Vaadin 8.1+ in 2.1.0
Vaadin 8.0+ in 2.0.0
Vaadin 8.2+ in 2.3.0
Vaadin 10 in 3.1.0
Vaadin 8.6+ in 2.3.1
Vaadin 13+ in 3.8.0
Vaadin 13 in 3.9.0
Vaadin 14+ in 4.0.0
Vaadin 18+ in 4.5.0
Vaadin 21+ in 5.0.0
Vaadin 20+ in 4.6.0
Vaadin 10+ in 3.0
Vaadin 23+ in 6.1.0
Browser
N/A

Crud UI Add-on - Vaadin Add-on Directory

Generate CRUD UIs for your entities/beans/POJOs at runtime Crud UI Add-on - Vaadin Add-on Directory
Crud UI Add-on provides an API to automatically generate CRUD-like UIs for any Java Bean at runtime. The API is defined through 4 interfaces: **`CrudComponent`**: A Vaadin `Component` that can be added to any `ComponentContainer`. This is the actual CRUD final users will see in the browser. **`CrudListener`**: Encapsulates the CRUD operations. You can implement this interface to delegate CRUD operations to your back-end. **`CrudLayout`**: Encapsulates layout-related behavior. **`CrudFormFactory`**: Builds the forms required by the CRUD UI. The add-on includes several implementations of these interfaces. # Basic usage Say, you have the following domain/entity/Java Bean class: ```java public class User { @NotNull // Validation API is required! Add it as a dependency on your project private Long id; @NotNull private String name; private Date birthDate; @Email private String email; @NotNull private String password; ... getters & setters ... } ```   You can create a new CRUD component and add it into any Vaadin layout as follows: ```java GridCrud crud = new GridCrud<>(User.class); layout.addComponent(crud); ```   You can enable _Java Bean Validation_ as follows: ```java crud.getCrudFormFactory().setUseBeanValidation(true); ```   Use lambda expressions or method references to delegate CRUD operations to your backend: ```java crud.setFindAllOperation(() -> backend.findAll()); crud.setAddOperation(backend::add); crud.setUpdateOperation(backend::update); crud.setDeleteOperation(backend::delete); ```   # Advanced usage As an alternative to method references and lambda expressions, you can implement a `CrudListener` to delegate CRUD operations to your backend: ```java crud.setCrudListener(new CrudListener() { @Override public Collection findAll() { return backend.findAllUsers(); } @Override public User add(User user) { return backend.add(user); } @Override public User update(User user) { return backend.update(user); } @Override public void delete(User user) { backend.remove(user); } }); ```   Use a different `CrudLayout` implementation: ```java GridCrud crud = new GridCrud<>(User.class, new HorizontalSplitCrudLayout()); ````   Set a custom `CrudFormFactory`: ```java CustomCrudFormFactory formFactory = new CustomCrudFormFactory<>(User.class); crud.setCrudFormFactory(formFactory); ```   Configure form fields visibility: ```java formFactory.setVisibleProperties(CrudOperation.READ, "name", "birthDate", "email", "groups", "mainGroup", "active"); formFactory.setVisibleProperties(CrudOperation.ADD, "name", "birthDate", "email", "password", "groups", "mainGroup", "active"); formFactory.setVisibleProperties(CrudOperation.UPDATE, "name", "birthDate", "email", "groups", "mainGroup", "active"); formFactory.setVisibleProperties(CrudOperation.DELETE, "name", "email"); ````   Use nested properties in `GridCrud` instances: ```java crud.getGrid().addColumn(user -> user.getMainGroup().getName()).setHeader("Main group").setKey("key"); ```   Configure the type of an input field: ```java formFactory.setFieldType("password", PasswordField.class); ```   Customize fields after their creation: ```java formFactory.setFieldCreationListener("birthDate", field -> ... your own logic here ...); ```   Define a `FieldProvider` to manually create a field: ```java formFactory.setFieldProvider("groups", user -> { CheckboxGroup checkboxes = new CheckboxGroup<>(); checkboxes.setItems(groups); checkboxes.setItemLabelGenerator(Group::getName); return checkboxes; }); ```   Or use one of the included `FieldProvider` implementations: ```java formFactory.setFieldProvider("groups", new CheckBoxGroupProvider<>("Groups", GroupRepository.findAll(), Group::getName)); ```   Set a `Converter`: ````java formFactory.setConverter("salary", new Converter() { @Override public Result convertToModel(String value, ValueContext valueContext) { return Result.ok(new BigDecimal(value)); // error handling omitted } @Override public String convertToPresentation(BigDecimal value, ValueContext valueContext) { return value.toPlainString(); } }); ```` Customize captions: ```java formFactory.setButtonCaption(CrudOperation.ADD, "Add new user"); crud.setRowCountCaption("%d user(s) found"); ```  
View on GitHub
Author Homepage
Crud UI Add-on API
Online Demo
Issue Tracker
Discussion Forum

Crud UI Add-on version 1.2
null

Crud UI Add-on version 1.3
null

Crud UI Add-on version 1.4
null

Crud UI Add-on version 1.5
null

Crud UI Add-on version 1.5.1
null

Crud UI Add-on version 1.6.0
null

Crud UI Add-on version 2.0.0
Compiled with Vaadin 8 compatibility packages

Crud UI Add-on version 2.1.0
Upgraded to Vaadin 8.1.4

Crud UI Add-on version 2.1.1
Small fixes and enhancements

Crud UI Add-on version 2.1.2
Several bug fixes and enhancements.

Crud UI Add-on version 2.1.3
Added VerticalSplitCrudLayout implementation.

Crud UI Add-on version 2.1.4
Added VerticalCrudLayout implementation Added Grid.setClickRowToUpdate(boolean) method

Crud UI Add-on version 2.1.5
Fixed cancel button when used with Grid.setClickRowToUpdate(true) Fixed form caption in VerticalCrudLayout

Crud UI Add-on version 2.3.0
Compiled with Vaadin Framework 8.2.0 (fixes NoSuchMethodError: com.vaadin.ui.Notification.show(Ljava/lang/String;)V)

Crud UI Add-on version 3.0
Added Vaadin 10 support. Thanks to Johannes Häyry for the contributions.

Crud UI Add-on version 3.1
Bug fixes.

Crud UI Add-on version 3.1.0

Crud UI Add-on version 3.2.0
Added lazy loading support

Crud UI Add-on version 3.3.0

Crud UI Add-on version 3.4.0
Fixed NPE. Added Renderer support in FieldProviders. Changed from Grid-based CheckBoxProvider to CheckboxGroup from Directory

Crud UI Add-on version 3.5.0
Added OffsetBasedPageRequest for Spring Data.

Crud UI Add-on version 3.6.0
Updated checkbox-group-java (which fixes a bug related to the slf4j-simple dependency).

Crud UI Add-on version 3.7.0

Crud UI Add-on version 3.7.1
Fixed strange bug when hiding forms. Fixed VerticalCrudLayout.

Crud UI Add-on version 2.3.1
Updated to Vaadin 8.6.4

Crud UI Add-on version 3.7.2
External notifications in GridCrud.

Crud UI Add-on version 3.7.3
Fixed #44 Needless scrollbars appear (w/ fix)

Crud UI Add-on version 3.8.0
Updated to Vaadin 13.0.1. Use vaadin-core dependency. Use Vaadin Flow's CheckboxGroup. Allow domain-object specific captions using CrudFormFactory.

Crud UI Add-on version 3.8.1
Allow setting values in FieldCreationListeners

Crud UI Add-on version 3.9.0

Crud UI Add-on version 4.0.0
- Updated to Vaadin 14.0.2 - Fixes #34 Method to set a Converter for a specific field

Crud UI Add-on version 4.0.1
Fixes #56 flow-build-info.json shoudn't be included in JAR

Crud UI Add-on version 4.1.0
* The Grid component in is no longer size full. * OffsetBasedPageRequest now uses Vaadin's QuerySortOrder (Spring Data).

Crud UI Add-on version 4.2.0
Loosen generic to allow use of TreeDataProvider Bumps up Vaadin version 14.1.25

Crud UI Add-on version 4.3.0
Fixes #67 this.domainType.newInstance(); Does not work with no public constructor.

Crud UI Add-on version 4.3.1
Fixes #59 Custom converter is not working in CrudFormFactory

Crud UI Add-on version 4.3.2
* Fixes #72 setFindAllOperationVisible always sets visibility to false, ignoring the passed value * Uses serializable versions of Producer and Consumer

Crud UI Add-on version 4.4.0
Updates to Vaadin 14.5.3 Fixes #82 Exceptions in CRUD operations show success message

Crud UI Add-on version 4.4.1
Fixes #92 Issue with dialog buttons in some use cases

Crud UI Add-on version 4.5.0
Updated to Vaadin 19.

Crud UI Add-on version 4.6.0
Fixes #94 Add support for colspan in DefaultCrudFormFactory Updated to Vaadin 20

Crud UI Add-on version 5.0.0
Updated to Vaadin 21.0.3.

Crud UI Add-on version 5.1.0
Adds TreeGridCRUD implementation which uses TreeGrid (contributed by Boniface Chacha).

Crud UI Add-on version 6.0.0
Vaadin 23 support. FieldProvider (PR #102, thanks XakepSDK for the contribution)

Crud UI Add-on version 6.1.0
- Show error messages from CrudOperationException when relevant - Provide ENTER shortcut for operation button on the form - New method on Grid to add an optional Update button column - New method on form factory to enable/disable notifications, cf. the existing method on Grid (All features contributed by Paul Parlett. Thanks a lot, Paul!)

Crud UI Add-on version 6.2.0
Requires Java 11 and Vaadin 23.1.3. Fixes base FieldProvider generics Thanks to Boniface Chacha for the contributions.

Crud UI Add-on version 7.0.0
Supports Vaadin 24

Crud UI Add-on version 7.1.0
- Bump several dependencies for Vaadin 24.0.5 (by Francisco A. Lozano) - Allow overriding behaviors in `AbstractAutoGeneratedCrudFormFactory` (by Francisco A. Lozano)

Crud UI Add-on version 7.1.2
Fixes #51 - Prevent form from closing if add/edit operation fails with exception. Scroll to added/updated item in GridCrud. Updated to Java 21 and Vaadin 24.4.4

Online