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 award winner. He currently works for MariaDB plc as a Developer Relations Engineer. Starting his coding journey at 13 with BASIC on a rudimentary black screen, Alejandro quickly transitioned to C, C++, and Java during his academic years at the National University of Colombia. Relocating first to the UK and then to Finland, Alejandro deepened his involvement in the open-source community. He’s a recognized figure in Java circles, credited with articles and videos amassing millions of views, and presentations at international events.

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!

Related

Vaadin video tutorials
·57 words·1 min
Vaadin News
Finally! After endless hours of rehearsal, screen recordings, audio recordings, film recordings, audio-image synchronization, editing work, and do it all over again, we have published the first 6 videos of 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
And the winners are: Iskael Diaz Marquez Camilo Gonzalez Packt Publishing has two copies of Vaadin 7 UI Design By Example to be given away to two lucky winners.
Enterprise App now available with Maven
·46 words·1 min
Vaadin UI News
Finally! I’ve managed to write a Maven POM for Enterprise App.