Enterprise-app for Vaadin

Some years ago I published the Enterprise-app add-on for Vaadin. The most awarded feature was the CrudComponent class that allowed you could add a CRUD-like interface to any Hibernate entity by writing one line of code. Enterprise-app was (and still is) available for Vaadin 6. I partially migrated it to Vaadin 7, but never really completed the task.

I'm not longer supporting the Enterprise-app add-on, but working in a set of new Vaadin add-ons to replace parts of its functionality. So far I have implemented the Crud UI add-on, with a less magical but much more flexible CrudComponent. A key difference with the old one is that it doesn't perform the actual CRUD operations, instead, it delegates the operations to a CrudListener with 4 methods that you have to implement (or alternatively, use 4 separte interfaces and lambda expressions or method references). This allows you to use any persistence technology you want.

Suppose you have a JavaBean like the following:

public class User {
    private Long id;
    private String name;
    private Date birthDate;
    private String email;
    private String password;
    
    ... getters & setters ...
}

And a "backend" service class like the following:

public class Backend {
    Collection<User> findAll() { ... }
    User add(User user) { ... }
    User update(User user) { ... }
    void delete(User user) { ... }
}

Then, with the Crud UI add-on, you can create a CRUD web interface with the following code:

GridBasedCrudComponent<User> crud = new GridBasedCrudComponent<>(User.class);
crud.setFindAllOperation(() -> backend.findAll());
crud.setAddOperation(backend::add);
crud.setUpdateOperation(backend::update);
crud.setDeleteOperation(backend::delete);

There are several configuration options. See the examples on the add-on's page. The following is an example of a CrudComponent with modified configuration settings for Grid's columns, field captions, layout, and validations:

If you were a user of Enterprise-app, take a look at the new Crud UI add-on and let me know any issues you find or features you would like to have.

Happy coding!

Comments

Popular Posts