From f63b1bd1a4bcea5046c2ee14765df07287f89912 Mon Sep 17 00:00:00 2001 From: Rhys Nute <nuterd@cardiff.ac.uk> Date: Wed, 13 Dec 2023 13:10:56 +0000 Subject: [PATCH] updated --- .../Organisation/organisationControllers.java | 2 ++ .../localauthority/localAuthority.java | 16 ++++++++-------- .../resources/templates/local-authorities.html | 6 +++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java b/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java index 4e25da2a..5e289e9f 100644 --- a/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java +++ b/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java @@ -21,6 +21,7 @@ public class organisationControllers { public ModelAndView getLocalAuthoritiesPage(){ ModelAndView mav = new ModelAndView("local-authorities"); List<localAuthority> localAuthority = localAuthorityRepository.getAllLocalAuthority(); + mav.addObject("localAuth", localAuthority); return mav; } @GetMapping("/localForm") @@ -33,6 +34,7 @@ public class organisationControllers { private localAuthorityRepository localAuthorityRepository; @PostMapping("/local-auth-data") public ModelAndView localAuthSent(@Valid @ModelAttribute("localAuthority")localAuthority localAuthority, BindingResult bindingResult, Model model ) { + List<localAuthority> localAuthorityList = localAuthorityRepository.getAllLocalAuthority(); if (bindingResult.hasErrors()){ ModelAndView modelAndView = new ModelAndView("local-auth-data", model.asMap()); return modelAndView; diff --git a/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java b/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java index 7bed36b9..eb84e592 100644 --- a/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java +++ b/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java @@ -19,15 +19,15 @@ public class localAuthority { private URL website; @Override public String toString() { - return "localAuthority" + - localAuthorityName + '\'' + - address1 + '\'' + - address2 + '\'' + - city + '\'' + - county + '\'' + - postcode + '\'' + + return "Local Authority:" + " " + + localAuthorityName + '\'' + " " + + address1 + '\'' + " " + + address2 + '\'' + " " + + city + '\'' + " " + + county + '\'' + " " + + postcode + '\'' + " " + website + - '.'; + " "; } public String getLocalAuthorityName() { diff --git a/src/main/resources/templates/local-authorities.html b/src/main/resources/templates/local-authorities.html index e416d25f..bdc00cdb 100644 --- a/src/main/resources/templates/local-authorities.html +++ b/src/main/resources/templates/local-authorities.html @@ -10,11 +10,11 @@ <body> <h1>Local Authorities</h1> <div id="councils"> - <ul th:each="localAuthority:${localAuthority}"> - <li th:text="${localAuthority}"></li> + <ul th:each="local:${localAuth}"> + <li th:text="${local}"></li> </ul> </div> -<a href="/localForm" id="authority"><button>Local Authorities please enter here</a></button> +<button><a href="/localForm" id="authority">Local Authorities please enter here</a></button> <footer th:insert="~{/towns/Templating.html::footer}"></footer> </body> </html> \ No newline at end of file -- GitLab