Awesome
Vaadin+Quarkus example project
Work on this project has been kindly sponsored by Inacta AG.
This project runs Vaadin 14 on top of Quarkus.
The JBoss Undertow Servlet container is used to run the Vaadin Servlet.
Vaadin 19 port is also available, please see the v19
branch.
Uses Vaadin Quarkus Extension to run smoothly on top of Quarkus.
Note: Starting with Vaadin 22, Quarkus is now an official Vaadin offering.
Demoed Vaadin features
Support for the following features is demoed in this project:
- Route and RouterLayout auto-discovery: see the
AboutRoute
,MainRoute
andPolymerExampleRoute
example route classes and theMainLayout
example layout class. - The PolymerTemplate-based components and forms: the
HelloWorld
component demoes a reusablePolymerTemplate
-based component with a customTemplateModel
, whileUserForm
demoes aPolymerTemplate
-based form with fields exposed to the server-side via the@Id
annotation. - Form validation via JSR-303,
BeanValidationBinder
and hibernate-validator. SeeUserForm
. - A custom
ServletContextListener
which is able to run certain functionality before the app starts; see theBootstrap
class for more details. - Both development and production modes are supported.
- Fast testing with Karibu-Testing.
See
src/test/java
for more details. - Dependency injection is supported: you can inject beans into Vaadin
@Route
-annotated views. See theDiRoute
for more details. - Adding third-party components from Vaadin Directory works.
See the
ThirdPartyRoute
. - Vaadin Push - the
PushDemoRoute
. - Bean events - demoes Vaadin-specific bean events being fired. See
EventsRoute
for more details. @ClientCallable
- seeClientCallableRoute
LitTemplate
: TheHelloWorld
component demoes a LitElement-based component with events and properties, whileUserForm
demoes aLitTemplate
-based for with fields exposed to the server-side via the@Id
annotation. Also aLitElement
-based component is demoed.- Routes registered dynamically in the
ServiceInitEvent
observer bean. - Vaadin-related event observers:
ServiceInitEvent
,SessionInitEvent
,UIInitEvent
, navigation events, etc. - Custom Vaadin service interfaces: custom
ErrorHandler
, customI18nProvider
, customSystemMessagesProvider
.
Known limitations:
- It's not possible to use a custom app-specific VaadinServlet currently:
see Vaadin #9755
for more details. However, the Vaadin-Quarkus Extension uses a custom
QuarkusVaadinServlet
.
Demoed Vaadin Versions
This demo uses Vaadin 14. For Vaadin 22+, see the official Vaadin offering.
Vaadin Quickstarter / Archetype
For a very simple Skeleton Starter app which can also serve as an archetype app, please see vaadin-quarkus-skeleton-starter.
Running the application in dev mode
You can run your application in dev mode that enables live coding using:
./mvnw -C clean compile quarkus:dev
Packaging and running the application in production mode
The application can be packaged using:
./mvnw -C clean package -Pproduction
It produces the code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
file in the /target
directory.
Be aware that it’s not an über-jar as the dependencies are copied into the target/lib
directory.
If you want to build an über-jar, execute the following command:
./mvnw -C clean package -Dquarkus.package.type=uber-jar -Pproduction
The application is now runnable using java -jar target/code-with-quarkus-1.0.0-SNAPSHOT-runner.jar
.
Creating a native executable
Unsupported.
How this works
The Quarkus-Undertow Servlet capabilities are used to take advantage of the Undertow Servlet Container, in order to run Vaadin Servlet seamlessly in the servlet environment.
Quarkus-Undertow integration needs special magic to auto-discover classes which Vaadin needs
to work properly (e.g. @NpmPackage
-annotated classes). Quarkus uses the Jandex Index;
the Jandex Index is available for Vaadin at vaadin-jandex
for more details.
Adding Third-party components
In order for Vaadin to correctly discover @NpmModule
-annotated classes
for third-party components added from Vaadin Directory, they need to package the
Jandex index. Often they don't, therefore it's important to take advantage
of quarkus.index-dependency
and add those third-party
components to application.properties
.
For example, in order to use the Multiselect ComboBox,
you need to add the following lines to your application.properties
:
quarkus.index-dependency.multiselect-combo-box-flow.group-id=org.vaadin.gatanaso
quarkus.index-dependency.multiselect-combo-box-flow.artifact-id=multiselect-combo-box-flow
License
See LICENSE for more details.