Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this post we are going to explain how to create a new element managed by the Platform. As a demostration we are going to create the concept of Model.

...

We have already defined our JPA Entity, the next step is to define its corresponding JPA Repository. The JPA Repositories are defined on the package com.minsait.onesait.platform.config.repository, so you have to create in this package the interface ModelRepository.java and define the methods you will need:

Note: don


Info

Don't forget to extends this interface of JpaRepository<Model, Long>


Finally, there is a module within the Platform that is in charge of creating and populating the tables on MySQL database defined on the onesaitplatform-config-model module, its name is onesaitplatform-config-init:

...

In this package we create the @Controller class ModelController.java


Info

...

We are using the annotation @RequestMapping of Spring Web, this annotation maps HTTP requests to handler methods of MVC and REST controllers. We also use the annotation @Slf4j for log.


The method we are going to create is for listing all the models that the user has. The controller will need another class for doing all the business logic, for this, we will use the module onesaitplatform-config-service where we have to create the package com.minsait.onesait.platform.config.services.model and inside of it we are going to create an interface and its implementations where we'll define all the functions necessary to implement our new funcionality:

...

If you remember, we used the class org.springframework.ui.Model to pass the list of models from controller to the front part, and now we are going to represent them in the HTML file.Note: to

Info

To create the HTML file we are going to use Thymeleaf.


Let's analyze the previous HTML code.

...