Skip to content
Snippets Groups Projects
Commit 5e306287 authored by Rhys Evans's avatar Rhys Evans
Browse files

cleared code, made addLocations element name easier to distinguish, fixed bug...

cleared code, made addLocations element name easier to distinguish, fixed bug with landamrk form not defaulting to select location/trail disabled selection dropdown option by default
parent 873e67ac
No related branches found
No related tags found
1 merge request!23Resolve "As a developer I want all landmarks to be stored together"
......@@ -53,12 +53,5 @@ public class location {
return locationTrailID;
}
// public location(int locationID, String locationName, String locationEmail, String locationDescription, String locationPlace, int locationTrailID) {
// this.locationID = locationID;
// this.locationName = locationName;
// this.locationEmail = locationEmail;
// this.locationDescription = locationDescription;
// this.locationPlace = locationPlace;
// this.locationTrailID = locationTrailID;
// }
}
......@@ -8,7 +8,7 @@ import java.util.List;
public interface locationRepository {
List<location> getAllLocation();
void addLocation(location llocation);
void addLocation(location loc);
}
......@@ -34,10 +34,10 @@ public class locationRepositoryJDBC implements locationRepository {
}
@Override // intended implementation at current: user data from templates/Landmarks/LandmarkFormTh.html is added to the location table, todo change location class to Location as its better code grammar and looks funky otherwise.
public void addLocation(location llocation) {
public void addLocation(location loc) {
String sql = "insert into locations(locationID, locationName , locationEmail,locationDescription,locationPlace, locationTrailID) values (?,?,?,?,?,?)";
jdbc.update(sql, llocation.getLocationID(),llocation.getLocationName(),llocation.getLocationEmail(),llocation.getLocationDescription(),llocation.getLocationPlace(),llocation.getLocationTrailID());
jdbc.update(sql, loc.getLocationID(),loc.getLocationName(),loc.getLocationEmail(),loc.getLocationDescription(),loc.getLocationPlace(),loc.getLocationTrailID());
}
......
package Team5.SmartTowns.Landmarks;
......@@ -32,7 +32,7 @@ public class LandmarksController {
@Autowired
private locationRepository locationRepository;
@PostMapping("/landmarkSub")
public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model, RedirectAttributes redirectAttributes ) {
public ModelAndView landmarkSent(@Valid @ModelAttribute("landmarkData") Landmarks landmarks, BindingResult bindingResult, Model model ) {
if (bindingResult.hasErrors()) {
......@@ -40,21 +40,10 @@ public class LandmarksController {
return modelAndView;
} else{
System.out.println(landmarks);
// JFrame frame = new JFrame("Main Window");
//
// JOptionPane.showMessageDialog(frame, "Message for the dialog box goes here.","Error", JOptionPane.ERROR_MESSAGE);
//
// frame.setSize(350,350);
// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// frame.setVisible(true);
location loc= new location(landmarks.getLandmarkID(),landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID());
System.out.println(loc);
locationRepository.addLocation(loc);
// redirectAttributes.addFlashAttribute("notification",
// String.format("Contractor \"%s\" successfully saved"));
// redirectAttributes.addFlashAttribute("msg", "Success");
ModelAndView modelAndView = new ModelAndView("redirect:/home");
return modelAndView;
......
......@@ -30,7 +30,8 @@
</label><br><br>
<label>Your Location:
<select th:field="*{landmarkLocation}">
<option value="" disabled selected>Select Location</option>
<option value="" hidden="true">Select Location</option>
<option value="" selected disabled>Select Location</option>
<option value="Caerphilly">Caerphilly</option>
<option value="Risca">Risca</option>
<option value="Penarth">Penarth</option>
......@@ -38,6 +39,7 @@
</label><br><br>
<label>Trail:
<select th:field="*{trailID}">
<option value=0 hidden="true">Select Trail</option>
<option value=0 disabled selected>Select Trail</option>
<option value=0101>(Caerphilly) Castle Trail</option>
<option value=0102>(Caerphilly) Pub Trail</option>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment