All articles

Jmix 1.2 Is Released

A few weeks ago we released Jmix framework and Studio version 1.2.

In this article, I will briefly describe the most noteworthy features introduced in the new release. You can find more information on the changes, along with upgrade instructions, on the What's New page of the documentation.

New Add-ons

Business Calendar

Business Calendar add-on provides API and UI for working with business days and hours.

Business calendars can be defined at design time using annotated Java interfaces, or at runtime through the application UI. In the latter case, the calendars are stored in the database.

The business calendar API provides methods to check if a given date and time are working hours, and to perform basic arithmetic operations with date and time considering the business hours defined by the calendar.

Notifications

Notifications add-on enables sending notifications to users via various message channels.

The add-on includes two channels out-of-the-box: the in-app channel shows notifications in the application UI, the email channel sends emails. You can define additional channels in your application.

In-app notifications are displayed to users by a special indicator component that can be placed to any application screen. The indicator shows the number of unread notifications.
When the user clicks on the indicator, the list of notifications is shown. The user can view notifications and mark them as read or unread:

20220327133229.png

The add-on also provides UI to create and send notifications, as well as API to send notifications programmatically in response to any system events.

Quartz

Jmix uses Quartz job scheduler to run asynchronous tasks. It's a great battle-proven and well known by developers engine, but a minimalistic integration with Quartz lacks some features necessary for many business applications: ability to configure tasks schedule and to start/stop tasks at the application run time. These features are present in the Quartz API, so we have decided to make them available through the Jmix application UI.

20220327133707.png

The Quartz add-on enables managing Quartz jobs via the application user interface. At design time, a developer defines jobs by implementing the org.quartz.Job interface. At runtime, a system administrator can configure the jobs, pause and resume jobs execution, trigger immediate execution of inactive jobs.

The add-on also supports job parameters that can be set in the UI and passed to the jobs.

Application Settings

Another common requirement for many applications is to have some configuration parameters that can be changed at runtime, without the application restart. Such parameters are often used by business functions and can define various thresholds, coefficients, URLs, etc.

Spring Boot provides a feature called "Configuration Properties", and Jmix uses it extensively for system-level parameters. Unfortunately, this feature is not convenient for working with mutable values, and obviously Spring Boot doesn't provide any integrated UI for managing the values at runtime.

We have considered different approaches, and came to the conclusion that the simplest and most effective way is to use JPA entities as sets of parameters stored in the database. JPA entities are already first-class citizens in Jmix, so settings based on entities automatically acquire a lot of useful features: distributed caching, ability to use all types of the data model, localization of parameter names, access control and audit of changes. Developers can use the entity designer in Studio to create settings classes.

The Application Settings add-on provides a base class for entities and a simple API to load and store a single instance of each settings entity. The client code uses regular entity getters and setters to access parameter values.

When creating a settings entity class, a developer can specify default values for parameters. A default value is returned when the parameter has null value in the database.

The add-on also provides a generic UI for managing settings:

20220327151039.png

OpenID Connect Integration

OpenID Connect add-on enables easy integration with OIDC providers (such as Keycloak, Okta, AWS Cognito, etc.) for external authentication and SSO.

In addition to authentication, it allows you to map OIDC claims to Jmix user's roles and attributes. Also, you can configure the add-on to create users in the application database automatically upon first login.

The add-on is now in incubating state, so please be aware that its API and behavior can change significantly in the future.

Studio Enhancements

Composite Projects

This is a long awaited feature: ability to develop multiple add-ons and applications in a single IDE project, without the need to publish add-ons for testing them in an application. We have figured out that many big applications are now developed as sets of functional modules located in add-ons, and target applications combine the add-ons in different combinations. A composite project containing all interrelated add-ons and applications greatly speeds up the development of the whole system, and is very helpful at least on the active stage of development. Also, it's very convenient for developing reusable add-ons together with their demo applications.

We leverage the Gradle's composite builds feature, when the settings.gradle file of the composite project includes subprojects using the includeBuild instruction, and Gradle replaces artefact dependencies with direct dependencies between subprojects.

Studio now fully supports such projects: it can create a composite project and add subprojects, correctly displays subprojects in the Jmix tool window and creates various project elements (entities, screens, etc.) in selected subprojects. It can also change common properties of all subprojects at once. Configuring dependencies between subprojects is on the way and will be included in one of the next Studio patches.

20220327164940.png

Code Snippets

Newcomers often stuck after the initial development stage when the Studio code generation features and visual designers cannot help anymore and programming against the framework API is required. The new code snippets palette allows developers to discover and employ the framework features more easily.

The code snippets palette is displayed on the right side of the IDE when a Java or Kotlin file is opened in the editor. The developer can drag and drop snippets from the palette to code. The snippets are context-dependent and may request parameters from the developer.

20220327170650.png

In addition to code snippets provided by the framework, you can define your own snippets in the application or add-on resources: Studio scans for snippets all files named jmix-code-snippets.xml in the project classpath. Use examples from the framework modules to write your snippets.

JPQL Designer

This is another feature that is designed to lower the entry barrier and simplify programming with Jmix.

The JPQL designer allows developers to define JPQL queries for loading entities and scalar values from the database. It is now opened automatically when you use the Data → Load … by query code snippets. In the near future, we’ll make it available also for creating and editing queries everywhere in the source code.

20220327172243.png

Jmix Tool Window

As a result of feedback from community, we've improved the representation of UI screens in the Jmix tool window. Now the User Interface section shows both screen descriptors and controllers, combined in a node with the screen's ID name:

20220327174320.png

For large projects with lots of entities and screens, we recommend using the new Group by Packages mode available in the Show Options Menu ("gear" button) of the tool window:

20220327173855.png

Conclusion

This article describes the most significant improvements in Jmix 1.2. The full list of changes in the initial release and in all subsequent patches is available in the changelog section of the documentation.

Thanks to all who contributed with their ideas, suggestions and bugreports!

Jmix is an open-source platform for building enterprise applications in Java