@RequestMapping(value = "/viewWarehouses", method = RequestMethod.GET) public String getItemView(Model model) { System.out.println("Hello " + leadDelegate.getAllWarehouses()); Iterable<Warehouse> dbWarehouses = leadDelegate.getAllWarehouses(); for (Warehouse warehouse : dbWarehouses) { System.out.println(warehouse.getName()); } model.addAttribute("myWarehouses", dbWarehouses); return "/lead/currentWarehouses"; }
@RequestMapping(value = "/submit", method = RequestMethod.POST) public String submit( @RequestParam("name") String name, @RequestParam("address") String address, @RequestParam("addressTwo") String addressTwo, @RequestParam("city") String city, @RequestParam("state") String state, @RequestParam("zipcode") String zipcode, Model model) { System.out.println("Creating warehouse"); Warehouse warehouse = new Warehouse(); warehouse.setName(name); warehouse.setAddress(address); warehouse.setAptNumber(addressTwo); warehouse.setCity(city); warehouse.setState(state); warehouse.setZipcode(zipcode); leadDelegate.saveWarehouse(warehouse); model.addAttribute(warehouse); return "/lead/warehouseAdded"; }