Getting Started
Esta página aún no está disponible en tu idioma.
Installation
- Create a new SpringBoot project using https://start.spring.io and select Web, JPA and a programing language for your Spring Boot app. DynamiaTools is compatible with Java, Groovy and Kotlin
- Download and import it in your IDE
- Add DynamiaTools starter dependency.
Maven
Gradle
Go to Maven Central to check last version.
This starter enable DynamiaTools in your application and add support for ZK, JPA and custom views and routes.
- Run and done
After running the application, open your browser and go to http://localhost:8080. You should see a blank page with a fully functional HTML template called Dynamical. Later will customize this page
First project
Let’s create something useful, like a contact CRUD to store our contact list. To create a CRUD in Dynamia Tools, follow these 3 steps:
- Create a JPA entity
- Create a Dynamia module
- Define a view descriptor for form and table views
1. Create a JPA entity
Let’s create a new class called Contact
and annotated with @Entity
to create a JPA entity. Add the fields name, email and
phone.
This is a simple POJO class annotated with standard JPA annotations. Note that you can also use Validations annotation
2. DynamiaTools modules
DynamiaTools modules are standard Spring component classes that implement the tools.dynamia.navigation.ModuleProvider
interface and return a new tools.dynamia.navigation.Module
object. Think of Dynamia modules as routers that define the navigation for pages.
Modules
includes an ID, name, pages and pages groups. On the other hand the Pages
include ID, name and path, which
in this case is represented by an entity Class. IDs
are crucial because they define the path for your pages. For instance,
the Contact
crud page has the path /pages/my-module/contacts
.
3. View descriptors
View descriptors define how the views for entities will be renderer in runtime. By default, DynamiaTools render views for Forms, Tables, Trees, Configs and others. In advanced guides you will learn how to customize view renderers and implement your own Views types.
Descriptors are YMLs
files with fields and parameters for entity classes. Lets create a folder for then in /resources/META-INF/descriptors
a
nd create the file ContactForm.yml
. The name of the file is not special but for good practice name it using the entity name and the view type.
Now create a view descriptor for the table view ContactTable.yml
4. Run and enjoy
Now your app has a new menu called My Module and a submenu called Contacts. This is a fully functional CRUD with create, read, update, delete and many more ready to use actions.
Table View
Form View
Customize your first project
Use standard Spring Boot application.properties
or application.yml
files to customize global settings for dynamia tools projects.
Use dynamia.app
properties groups for dynamia tools.
Re-run your application and this time is beautiful app
Responsive
Dynamical is a Bootstrap 5 free template fully responsive, check https://github.com/dynamiatools/theme-dynamical for documentation
Automatic REST
You’ve just built a full-stack project with DynamiaTools in about 10-15 minutes. Your project includes some special features,
one of which is an automatic RESTful endpoint for all CrudPages
. Create some contacts in the front end, then replace the browser
URL with http://localhost:8080/api/my-module/contacts.
You should see a JSON response with your contacts. In my case, I received the following response:
Then navigate to http://localhost.com:8080/api/my-module/contacts/1 and get info of contact with ID = 1
Check that DynamiaTool default json form has this form:
Congratulations
With this Getting Started guide, you’ve just built a web application with automatic CRUD support, automatic RESTful endpoints, and a responsive template. Continue with the following guides to learn advanced topics with DynamiaTools.