Code Snippets

Studio provides code snippets to improve the developer experience. The Code Snippets palette is available by clicking the Code Snippets button in the editor window top panel for Spring beans and UI controllers.

snippet window

You can just drag the necessary snippet from the palette to your code. Snippets are context-dependent and may request parameters from the developer.

In the example below, the Get localized message code snippet is dragged to the code, and the dialog requesting key message appeared.

snippet example

The result of adding the code snippet will be the following:

snippet example result

When you use code snippets that load data by query, the JPQL designer is automatically opened. The JPQL designer allows you to define JPQL queries for loading entities and scalar values from the database.

This feature is free to use in small projects with up to 10 entities and roles. In a larger project, it requires a RAD or Enterprise subscription.

In the example below, the JPQL designer is appeared after dragging the Load list of entities by query code snippet.

snippet query

In the result, the following code will be added:

snippet query result

All code snippet templates are located in jmix-code-snippets.xml files inside the relevant framework modules. You can define your own snippets on the project or an add-on level: just create a jmix-code-snippets.xml file in the project’s resources using an example from the framework.