View finish!

This commit is contained in:
coliveira 2019-08-09 17:08:55 -03:00
parent 75fe7380cb
commit 805c176081
4 changed files with 37 additions and 6 deletions

View file

@ -1,4 +1,14 @@
package org.springframework.samples.petclinic.products; package org.springframework.samples.petclinic.products;
public class Product { public class Product {
private String description;
private String name;
public Product(String description, String name){
this.description = description;
this.name = name;
}
public String getDescription() { return description; }
public String getName() { return name; }
} }

View file

@ -14,7 +14,9 @@ public class ProductsController {
@GetMapping("/products") @GetMapping("/products")
public String showProductList(Model model){ public String showProductList(Model model){
List<Product> prods = new ArrayList<Product>(); List<Product> prods = new ArrayList<Product>();
model.addAttribute("Products", prods); model.addAttribute("products", prods);
prods.add(new Product("Produto 1", "p1"));
prods.add(new Product("Produto 2", "p2"));
return "products/productsList"; return "products/productsList";
} }

View file

@ -59,9 +59,9 @@
<span>Veterinarians</span> <span>Veterinarians</span>
</li> </li>
<li th:replace="::menuItem ('/oups','error','trigger a RuntimeException to see how it is handled','warning-sign','Error')"> <li th:replace="::menuItem ('/products','products','products list','ph-list','products')">
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span> <span class="glyphicon glyphicon-ph-list" aria-hidden="true"></span>
<span>Error</span> <span>ProductList</span>
</li> </li>
</ul> </ul>

View file

@ -1,10 +1,29 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en">
<html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'products')}">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
</head> </head>
<body> <body>
<h3>asdasdasdad</h3>
<h2>Product List</h2>
<table id="products" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr th:each="product : ${products}">
<td th:text="${product.name}"></td>
<td th:text="${product.description}"></td>
</tr>
</tbody>
</table>
</body> </body>
</html> </html>