- Timestamp:
- 02/03/24 17:15:01 (9 months ago)
- Branches:
- master
- Children:
- d4d8fb9
- Parents:
- 501396e
- Location:
- src/main
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/cookbook/controller/HomeController.java
r501396e raea04dd 2 2 3 3 4 import com.example.cookbook.model.Komentar; 4 5 import com.example.cookbook.model.Recept; 5 6 import com.example.cookbook.model.Slika; 6 7 import com.example.cookbook.model.Sostojka; 7 8 import com.example.cookbook.model.exception.ReceptNeEPronajdenException; 9 import com.example.cookbook.service.KomentariService; 8 10 import com.example.cookbook.service.ReceptService; 9 11 import com.example.cookbook.service.SlikiService; … … 25 27 private final SostojkiService sostojkiService; 26 28 27 public HomeController(ReceptService receptService, SlikiService slikiService, SostojkiService sostojkiService) { 29 private final KomentariService komentariService; 30 31 public HomeController(ReceptService receptService, 32 SlikiService slikiService, 33 SostojkiService sostojkiService, KomentariService komentariService) { 28 34 29 35 this.receptService = receptService; 30 36 this.slikiService = slikiService; 31 37 this.sostojkiService = sostojkiService; 38 this.komentariService = komentariService; 32 39 } 33 40 … … 51 58 List<Slika> sliki; 52 59 List<Sostojka> sostojki; 60 List<Komentar> komentari; 53 61 try { 54 62 recept = receptService.findById(id); 55 63 sliki = slikiService.findAllPicById(id); 56 64 sostojki = sostojkiService.findAllById(id); 65 komentari = komentariService.findAllById(id); 57 66 } catch (SQLException e) { 58 67 return "redirect:/error-page/SQL%20Exception"; … … 63 72 model.addAttribute("sliki", sliki); 64 73 model.addAttribute("sostojki", sostojki); 74 model.addAttribute("komentari", komentari); 65 75 return "recept"; 66 76 } -
src/main/resources/templates/recept.html
r501396e raea04dd 11 11 margin: 16px; 12 12 border-style: groove; 13 } 14 textarea{ 15 width: 70%; 13 16 } 14 17 </style> … … 67 70 </div> 68 71 72 <form class="p-4 border" th:method="POST" th:action="@{'/komentar/{id}' (id=${recept.recId})}"> 73 <div class="pt-3"> 74 <label for="kom-ocena">Внеси оцена</label> 75 <input id="kom-ocena" name="ocena" type="number" min="1" max="10" step="1" required> 76 </div> 69 77 70 <div class="mt-4">KOMENTARI TO DO</div> 78 <div class="pt-3"> 79 <textarea name="komentar">Внеси коментар..</textarea> 80 </div> 81 <div class="pt-3"> 82 <label for="telefon">Избери телефон</label> 83 <select id="telefon" name="telefon" required> 84 <option selected></option> 85 <option th:each="tel : ${telefoni}" th:text="tel" th:value="tel"></option> 86 </select> 87 </div> 88 <div class="pt-3"> 89 <button>Submit</button> 90 </div> 91 </form> 92 93 <div class="mt-4"> 94 <div th:each="komentar : ${komentari}" class="border p-4"> 95 <p th:text="${komentar.imePrezime}">Ime Prezime</p> 96 <p th:text="${komentar.getDataFormatirana()}">2022-12-09 18:25:58</p> 97 <p th:text="${komentar.ocena}">8</p> 98 <p th:text="${komentar.text}" class="border">text</p> 99 </div> 100 </div> 71 101 </div> 72 102
Note:
See TracChangeset
for help on using the changeset viewer.