diff --git a/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java b/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java index 014a86a17fa2a1efe14504e9907b613777e7558f..05cfe0bacd7b0a0cfb54329182f49025533f2311 100644 --- a/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java +++ b/src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java @@ -21,15 +21,20 @@ public class organisationControllers { public ModelAndView getLocalAuthoritiesPage(){ ModelAndView mav = new ModelAndView("local-authorities"); List<localAuthority> localAuthority = localAuthorityRepository.getAllLocalAuthority(); - mav.addObject("localAuthority", localAuthority); return mav; } + @GetMapping("/localForm") + public ModelAndView getLocalAuthForm(){ + ModelAndView modelAndView = new ModelAndView("local-auth-data.html"); + modelAndView.addObject("localAuthority",new localAuthority()); + return modelAndView; + } @Autowired private localAuthorityRepository localAuthorityRepository; - @GetMapping("/local-auth-data") + @PostMapping("/local-auth-data1") public ModelAndView localAuthSent(@Valid @ModelAttribute("localAuthority")localAuthority localAuthority, BindingResult bindingResult, Model model ) { if (bindingResult.hasErrors()){ - ModelAndView modelAndView = new ModelAndView("local-auth-data", model.asMap()); + ModelAndView modelAndView = new ModelAndView("local-auth-data.html", model.asMap()); return modelAndView; }else{// converts user input using the organisation constructor into a submittable format to the sql table @@ -40,7 +45,7 @@ public class organisationControllers { return modelAndView; } } - @PostMapping + @GetMapping("/businesses") public ModelAndView getBusinessesPage(){ ModelAndView mav1 = new ModelAndView("Businesses"); diff --git a/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java b/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java index 0915dcddbe126e26fce6b1a35b5e41bce24a0f60..3a07cde4912861b3ff3a3dade143b079fb3f221b 100644 --- a/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java +++ b/src/main/java/Team5/SmartTowns/localauthority/localAuthority.java @@ -2,10 +2,12 @@ package Team5.SmartTowns.localauthority; import lombok.AllArgsConstructor; import lombok.Data; +import lombok.NoArgsConstructor; import java.net.URL; @AllArgsConstructor +@NoArgsConstructor @Data public class localAuthority { private String localAuthorityName; diff --git a/src/main/resources/static/local-auth-data.html b/src/main/resources/templates/local-auth-data.html similarity index 91% rename from src/main/resources/static/local-auth-data.html rename to src/main/resources/templates/local-auth-data.html index abacfb46cf8bad3e393f23084e7e51a868991cf7..3bfcf75d6428e7f5c698d21a532e21d4f9dff7d2 100644 --- a/src/main/resources/static/local-auth-data.html +++ b/src/main/resources/templates/local-auth-data.html @@ -5,13 +5,13 @@ <title>Local Authority</title> <link rel="stylesheet" th:href="@{css/localAuthortyPageStyle.css}"> - <link rel="stylesheet" th:href="@{css/templatingstyle.css}"> + <link rel="stylesheet" th:href="@{../static/css/templatingstyle.css}"> </head> <header th:insert="~{/towns/Templating.html::header}"></header> <body> <div id="container1"> <h2>Enter your Local authority</h2> - <form action="/local-auth-data" method="post" id="data" object="local-auth-data"> + <form action="/local-auth-data1" method="post" id="data"> <p> <label for="localAuthorityName">Enter your local authority</label> <input type="text" name="authority_name" id="localAuthorityName"> diff --git a/src/main/resources/templates/local-authorities.html b/src/main/resources/templates/local-authorities.html index 43d7e07f587777896105986e52521a7a1b50c02b..577f8fdcbd649e8aff39ca40eb1ea4325c7509a5 100644 --- a/src/main/resources/templates/local-authorities.html +++ b/src/main/resources/templates/local-authorities.html @@ -14,7 +14,7 @@ <li th:text="${localauthorities}"></li> </ul> </div> -<button><a href="../static/local-auth-data.html" id="authority">Local Authorities please enter here</a></button> +<button><a href="local-auth-data.html" 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