Spring Boot: View
Spring Boot View
📘 View
The view
is responsible for presenting the data to the user.
Java developers have several options to create frontend applications:
- whether it’s the server-side approach of
Vaadin
(it is a nice alternative in two flavors:Hilla
andFlow
), - the rich
client capabilities
ofJavaFX
, - the
HTML
server-side renderingThymeleaf
templates engine - or the native look and feel of
SWT
,
there is a Java-based
frontend solution to suit various development needs.
1 Java View
Java
, although primarily known for its backend capabilities, can be utilized in various ways to develop frontend applications.Here are some notable frameworks and approaches that enable us to create robust frontend solutions with
Java
andSpring Boot
.
1.1 HTML
In Spring Boot Server-Side HTML
version, views are typically implemented using template engines such as:
Thymeleaf
: ThymeleafFreeMarker
: Apache FreeMarker™ is a template engine: a Java library to generate text output (HTML web pages, e-mails, configuration files, source code, etc.) based on templates and changing data.Groovy
: Spring Boot officially provided starter to use Groovy Template for MVC and offline rendering.
The view can access the model and use it to generate the HTML
, JSON
or XML
that is sent to the user’s browser.
1.2 Vaadin
Vaadin Flow
Vaadin
Flow is a Java framework that allows developers to build rich, interactive web UIs entirely in Java. Here are its key features:
- UI Development in Java: Write UIs 100% in Java, eliminating the need to touch frontend technologies like HTML, CSS, and JavaScript.
- Pre-built Components: Offers a vast collection of high-quality, pre-built components to enhance user experience.
- Server-side Architecture: Simplifies security implementations and integrates well with Java EE and Spring ecosystems[5].
Vaadin Hilla
Vaadin
Hilla is a newer approach that combines the strengths of Vaadin
with modern frontend technologies. Here’s what it offers:
- TypeScript and Java Integration: Allows developers to write frontend code in TypeScript while still leveraging Java for the backend.
- Reactive Programming: Supports reactive programming models, making it easier to manage complex UI updates.
- Interoperability: Enables seamless interaction between Java and TypeScript code, providing a hybrid development experience[5].
1.3 JavaFX
JavaFX
is a set of graphics and media packages for designing, creating, and deploying rich client applications.
- Cross-Platform Compatibility: Operates consistently across diverse platforms.
- CSS Styling and FXML: Enhances customization and layout management with CSS styling and FXML support.
- Built-in UI Components: Offers a comprehensive set of built-in UI components and 3D graphics support.
- Performance: Better performance for complex UIs compared to Swing, although it has a steeper learning curve[5].
1.4 SWT
SWT
(Standard Widget Toolkit) is a graphical widget toolkit developed by IBM and part of the Eclipse
Foundation.
- Native Look and Feel: Provides a native look and feel by using the underlying OS’s graphical control elements.
- Performance: Generally offers better performance for GUI applications than Swing due to its use of native components.
- Eclipse Integration: Tight integration with the
Eclipse IDE
makes it a preferred choice for developers working within that environment[5].
1.5 Other Alternatives
Blazor (via.NET and C#)
Although not directly a Java framework
, Blazor
can be an interesting alternative for Java
developers familiar with.NET and C#.
- C# to Web Assembly: Compile C# code to Web Assembly to run in the browser or server-side.
- Interoperability: Interop with other JavaScript libraries such as React or Vue.
- Cross-Platform: Build for web, mobile, desktop, and more using.NET[2].
Scala.js
For developers comfortable with Scala
,Scala.js
can be a viable option.
- Scala to JavaScript: Transpile applications written in Scala into JavaScript.
- Correctness, Performance, and Interoperability: Boasts correctness, performance, and interoperability with other JavaScript frameworks[2].