Changeset 5f53114 for Prototype Application
- Timestamp:
- 03/05/23 17:35:54 (20 months ago)
- Branches:
- main
- Children:
- 8b7dd7f
- Parents:
- 9358bff
- Location:
- Prototype Application/Paw5/src/main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Prototype Application/Paw5/src/main/java/finki/paw5/web/controllers/PostController.java
r9358bff r5f53114 77 77 78 78 @GetMapping("/adoption-posts") 79 public String getAdoptionPosts(Model model , HttpServletRequest request){79 public String getAdoptionPosts(Model model){ 80 80 81 81 List<Post> posts = this.postService.findAll(); 82 82 List<Pet> pets = this.petService.listpets(); 83 //model.addAttribute("posts", posts); 84 //model.addAttribute("pets",pets); 85 request.getSession().setAttribute("posts",posts);//temp 86 request.getSession().setAttribute("pets",pets);//temp 83 model.addAttribute("posts", posts); 84 model.addAttribute("pets",pets); 87 85 88 86 return "list-posts-adoption"; … … 90 88 91 89 @GetMapping("/pet-details-{id}") 92 public String getPostDetails(@PathVariable Integer id, Model model, HttpServletRequest request){ 90 public String getPostDetails(@PathVariable Integer id, 91 Model model){ 93 92 94 93 Post post = this.postService.findById(id).get(); 95 94 Pet pet = this.petService.findById(post.getPetId()); 96 95 97 //model.addAttribute("pet", pet); 98 //model.addAttribute("post", post); 99 request.getSession().setAttribute("post", post);//temp 100 request.getSession().setAttribute("pet", pet);//temp 101 102 if(pet.getAdoptionId() != null){ 103 request.getSession().setAttribute("disableAdoption", true); 104 } else{ 105 request.getSession().setAttribute("disableAdoption", false); 106 } 96 model.addAttribute("pet", pet); 97 model.addAttribute("post", post); 107 98 108 99 return "pet-details"; -
Prototype Application/Paw5/src/main/resources/templates/list-posts-adoption.html
r9358bff r5f53114 1 1 <!DOCTYPE html> 2 2 <html xmlns="http://www.w3.org/1999/xhtml" 3 xmlns:th="http:// www.thymeleaf.org"3 xmlns:th="http://thymeleaf.org" 4 4 xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" 5 5 xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> … … 45 45 <th>Species</th> 46 46 </tr> 47 <tr th:each = "post : ${ session.posts}">47 <tr th:each = "post : ${posts}"> 48 48 <td th:text = "${post.getId()}"></td> 49 <td th:each = "pet : ${ session.pets}" th:if="${post.getPetId()==pet.getId()}" th:text = "${pet.getName()}"></td>50 <td th:each = "pet : ${ session.pets}" th:if="${post.getPetId()==pet.getId()}" th:text = "${pet.getSpecies()}"></td>49 <td th:each = "pet : ${pets}" th:if="${post.getPetId()==pet.getId()}" th:text = "${pet.getName()}"></td> 50 <td th:each = "pet : ${pets}" th:if="${post.getPetId()==pet.getId()}" th:text = "${pet.getSpecies()}"></td> 51 51 <td> 52 52 <form th:action="@{'/pet-details-{id}' (id=${post.getId()})}" -
Prototype Application/Paw5/src/main/resources/templates/pet-details.html
r9358bff r5f53114 1 1 <!DOCTYPE html> 2 2 <html xmlns="http://www.w3.org/1999/xhtml" 3 xmlns:th="http:// www.thymeleaf.org"3 xmlns:th="http://thymeleaf.org" 4 4 xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" 5 5 xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> … … 41 41 <tr> 42 42 <th>Post ID</th> 43 <td th:text = "${ session.post.getId()}"></td>43 <td th:text = "${post.getId()}"></td> 44 44 <tr> 45 45 <th>Pet Name</th> 46 <td th:text = "${ session.pet.getName()}"></td>46 <td th:text = "${pet.getName()}"></td> 47 47 </tr> 48 48 <tr> 49 49 <th>Species</th> 50 <td th:text = "${ session.pet.getSpecies()}"></td>50 <td th:text = "${pet.getSpecies()}"></td> 51 51 </tr> 52 52 <tr> 53 53 <th>Breed</th> 54 <td th:text = "${ session.pet.getBreed()}"></td>54 <td th:text = "${pet.getBreed()}"></td> 55 55 </tr> 56 56 <tr> 57 57 <th>Gender</th> 58 <td th:text = "${ session.pet.getGender()}"></td>58 <td th:text = "${pet.getGender()}"></td> 59 59 </tr> 60 60 <tr> 61 61 <th>Age Group</th> 62 <td th:text = "${ session.pet.getAgeGroup}"></td>62 <td th:text = "${pet.getAgeGroup}"></td> 63 63 </tr> 64 64 <tr> 65 65 <th>Size</th> 66 <td th:text = "${ session.pet.getSize()}"></td>66 <td th:text = "${pet.getSize()}"></td> 67 67 </tr> 68 68 </table> 69 69 <form method="POST" 70 th:action="@{'/submit-adopton-{id}' (id=${session.pet.getId()})}" 71 th:if="${session.pet.getAdoptionId()==null}"> 72 <button id="submit" type="submit">Adopt</button> 70 th:action="@{'/submit-adopton-{id}' (id=${pet.getId()})}" 71 th:if="${pet.getAdoptionId()==null}"> 72 <button id="submit" 73 type="submit" 74 class="btn">Adopt</button> 73 75 </form> 74 76
Note:
See TracChangeset
for help on using the changeset viewer.