Skip to main content

Enterprise-app for Vaadin

·314 words·2 mins
Vaadin News
Alejandro Duarte
Author
Alejandro Duarte
Alejandro Duarte is a Software Engineer, published author, and Developer Relations Engineer at MariaDB. He has been programming computers since the mid-90s. Starting with BASIC, Alejandro transitioned to C, C++, and Java during his academic years at the National University of Colombia. He relocated first to the UK and then to Finland to foster his involvement in the open-source industry. Alejandro is a recognized figure in Java and MariaDB circles.

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:

Crud UI add-on for Vaadin

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!

Enjoyed this post? I can help your team implement similar solutions—contact me to learn more.

Related

Vaadin video tutorials
·57 words·1 min
Vaadin News
Announcing the release of the first 6 videos in the Vaadin Tutorial series.
Book Give-away: Win a free copy of the book "Vaadin 7 UI Design By Example" - Just by commenting!
·246 words·2 mins
Vaadin News
Participate in a contest to win a free copy of the book “Vaadin 7 UI Design By Example” by commenting on this post.
Enterprise App now available with Maven
·46 words·1 min
Vaadin UI News
Learn how to add the Enterprise App Vaadin plug-in to your Maven project for Vaadin.