Skip to content

Library5: ThymeLeaf Web Project

Albert edited this page Jun 10, 2022 · 32 revisions

Welcome to the cifojava2022-3 wiki!

Spring Boot Projects: Library5

Base project

  • Base project:

    • @Entity book and List<Book>
    • POM
    • ThymeLeaf dependency
  • To work from base-project

    • DataBase H2: Library2
    • Application.properties
    • Command Line Runner with methods to test
    • @Service, @CrudRepository JPA 2.0, @Component
    • @Test JUnit Jupiter

New tools

  • ThymeLeaf Templates Engine
    • Most Thymeleaf attributes allow their values to be set as or containing expressions, which we will call Standard Expressions because of the dialects they are used in. These can be of five types:

       ${...} : Variable expressions.
       *{...} : Selection expressions.
       #{...} : Message (i18n) expressions.
       @{...} : Link (URL) expressions.
       ~{...} : Fragment expressions.
      
    • Attributes th:

      message: <p th:text="#{msg.welcome}">Welcome everyone!</p>
      list: <li th:each="book : ${books}" th:text="${book.title}">En las Orillas del Sar</li>
      link: <form th:action="@{/createOrder}">
      action: <input type="button" th:value**="#{form.submit}" />
      path: `<a th:href="@{/admin/users}">` 
      
    • How to write th:

      ThymeLeaf

Versions

  • version 1.0 : basic project from library

  • version 2.0 : evolving project with:

    • POM with new dependencies
    • H2-DB library5 with:
      • application.properities
      • @Entity
      • @CrudRepository
    • @Controller and @Service
    • new HTML: newBook
    • some basic refactoring
    • What exactly does Chrome render? And what does Thymeleaf do?
      • Chrome dev inspector Chrome dev inspector

      • ThymeLeaf ThymeLeaf

  • version 3.0 : Commit #2 : v3.0 read, create and delete with THYMELEAF and W3.CSS

    - Create, Read and Update
        ![ThymeLeaf](https://drive.google.com/uc?id=1hy5liJHH9Bm6prp6XS6Y__bYXGrQ4_C2)
    
Clone this wiki locally