thymeleaf

How to position two elements next to each other

心已入冬 提交于 2020-07-22 21:50:53
问题 I am rendering HTML page with Thymeleaf. I have user names which I display on top right screen. I want to add a link which I display if user hasn't validated his email. I am trying to make the link appear after the user name in brackets. Here is this part of the HTML <div th:if="${isLogged}" class="div-block-10"> <div class="user_name" th:text="${user.getFirstName() + ' ' + user.getLastName()}">Your Name</div> <div th:if="${!user.isEmailValidated()}" class="div-block-13"> <div class="email

thymeleaf get first 3 objects

喜夏-厌秋 提交于 2020-07-22 11:12:09
问题 Could you please help me. I want to display my first 3 objects from product, I don't how it must be. I try to use thymeleaf sequence, but it don't work. Maybe somebody can hint me how it could be done. HTML: <th:block th:each="product:${products}"> <a th:class="production_Page" th:href="@{'product/'+${product.id}}"> <p th:text="${product.productName}"/></a> <a th:class="production_Page" th:href="@{'productDelete/'+${product.id}}">Delete</a> <a th:class="production_Page" th:href="@{

Change of multiple select handling in Spring Boot 2.3.1

笑着哭i 提交于 2020-07-09 05:13:58
问题 Just faced a wired change of behavior after upgrading the Spring Boot version from 2.3.0 to 2.3.1 There is such a simple Thymleaf view with multi-select control <div class="form-group"> <label for="roles">Roles</label> <select multiple class="form-control" id="roles" th:field="*{roles}" required> <option th:each="role : ${roles}" th:text="${role.name}" th:value="${role.id}" th:selected="${user.roles?.contains(role)}"></option> </select> </div> and POST handling controller method @PostMapping

What kind of a solution is thymeleaf?

爱⌒轻易说出口 提交于 2020-07-04 10:01:06
问题 I read that thymeleaf is preferred instead of JSP nowadays. Which problem does thymeleaf solve that JSP can't? How is thymeleaf compared to other templating engines? 回答1: Well, this is really an opinion-based question and such will be my answer :) The main difference is that JSPs are compiled to Java servlet classes whereas Thymeleaf reads the template file, parses its DOM and then applies the model to it. This introduces a performance overhead and gives JSPs a performance edge, even with

How to populate dropdown list by previous selection Spring thymeleaf

喜你入骨 提交于 2020-06-28 05:30:54
问题 I need to create a second dropdown list based on previous selection. Basically user needs to select the screening and other dropdownlist has to show the seats for the selected screeing. My Controller @RequestMapping("/movieDetail") public String movieDetail( @PathParam("id") Long id, Model model, Principal principal ) { if(principal != null) { String username = principal.getName(); User user = userService.findByUsername(username); model.addAttribute("user", user); } Movie movie = movieService

How to persist data from the entity class and combined with data transfer object?

纵饮孤独 提交于 2020-06-17 13:15:31
问题 I'm working on an authentication feature and have run into an issue with persisting the data from the entity class. I'm able to access the password_hash and the username from the data transfer object but am not able to see the email, firstName, lastName, or phoneNumber from the User class in the database. The photo below is an example of what happens when I register a new user. You can see that there are 4 columns without data. When I'm adding a newUser I use a processRegistrationForm method

how we can bind a list of a list of object using thymeleaf

£可爱£侵袭症+ 提交于 2020-06-16 19:18:12
问题 I have a form where the user can add as much as he want of Table object that also can contains as much as he want of Columns object (like building tables in SQL).. I've tried the code bellow but nothing works and the form dosnt appear anymore when I've tried to bind the two lists. Controller @ModelAttribute("page") public Page getTable() { TableColumn column = new TableColumn(); List<TableColumn> columns = new ArrayList<>(); columns.add(column); Table table = new Table(); table.setColumns

how we can bind a list of a list of object using thymeleaf

自作多情 提交于 2020-06-16 19:16:49
问题 I have a form where the user can add as much as he want of Table object that also can contains as much as he want of Columns object (like building tables in SQL).. I've tried the code bellow but nothing works and the form dosnt appear anymore when I've tried to bind the two lists. Controller @ModelAttribute("page") public Page getTable() { TableColumn column = new TableColumn(); List<TableColumn> columns = new ArrayList<>(); columns.add(column); Table table = new Table(); table.setColumns

how we can bind a list of a list of object using thymeleaf

喜夏-厌秋 提交于 2020-06-16 19:16:11
问题 I have a form where the user can add as much as he want of Table object that also can contains as much as he want of Columns object (like building tables in SQL).. I've tried the code bellow but nothing works and the form dosnt appear anymore when I've tried to bind the two lists. Controller @ModelAttribute("page") public Page getTable() { TableColumn column = new TableColumn(); List<TableColumn> columns = new ArrayList<>(); columns.add(column); Table table = new Table(); table.setColumns

Thymeleaf: validation error by field

烂漫一生 提交于 2020-06-12 07:57:20
问题 Using Thymeleaf + Spring and form validation, I want to display errors that are related to a field next to this field. <input type="text" th:field="*{companyName}" class="form-control" placeholder="Code client" th:errorClass="'error'"/> If the field has an error, the class "error" is applied indeed. But is there an easy way to display also the validation error of the field? 回答1: Use this code to display error: <p class="alert alert-danger" th:if="${#fields.hasErrors('companyName')}" th:errors