Skip to content
Snippets Groups Projects
Commit 7286aee9 authored by Haoyu Sun's avatar Haoyu Sun
Browse files

add new secondhand item itemform

parent d820e816
No related branches found
Tags update-ci-and-build
1 merge request!1Dev
...@@ -3,6 +3,7 @@ package uk.ac.cf.spring.demo.takeaway.index; ...@@ -3,6 +3,7 @@ package uk.ac.cf.spring.demo.takeaway.index;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import java.util.List; import java.util.List;
...@@ -27,4 +28,18 @@ public class ExchangeController { ...@@ -27,4 +28,18 @@ public class ExchangeController {
modelAndView.addObject("exchangeItem", exchangeItem); modelAndView.addObject("exchangeItem", exchangeItem);
return modelAndView; return modelAndView;
} }
// add new ExchangeItem
@GetMapping("/exchange/add")
public ModelAndView addExchangeItem() {
ModelAndView modelAndView = new ModelAndView("/page/itemForm");
return modelAndView;
}
// address form
@PostMapping("/exchangeItem")
public ModelAndView addExchangeItem(ExchangeItem exchangeItem) {
ExchangeService exchangeService = ExchangeService.getInstance();
exchangeService.addExchangeItem(exchangeItem);
ModelAndView modelAndView = new ModelAndView("redirect:/exchange");
return modelAndView;
}
} }
...@@ -5,6 +5,51 @@ ...@@ -5,6 +5,51 @@
<title>Title</title> <title>Title</title>
</head> </head>
<body> <body>
<div>itemForm</div> <!-- <form action="/exchangeItem" method="post">-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label" for="name">Name</label>-->
<!-- <input class="form-control" type="text" id="name" placeholder="ExchangeItem Name">-->
<!-- </div>-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label" for="description">Description:</label>-->
<!-- <input class="form-control" id="description" placeholder="Description" type="text"/>-->
<!-- </div>-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label" for="exchangeOrNot">exchangeOrNot?</label>-->
<!-- <input checked class="form-check-input" id="exchangeOrNot" name="exchangeOrNot" type="checkbox"/>-->
<!-- </div>-->
<!-- <div class="mb-3">-->
<!-- <label class="form-label" for="moneyOrNot">moneyOrNot?</label>-->
<!-- <input checked class="form-check-input" id="moneyOrNot" name="moneyOrNot" type="checkbox"/>-->
<!-- </div>-->
<!-- <div class="mb-3">-->
<!-- <button class="btn btn-primary">Submit</button>-->
<!-- </div>-->
<!-- </form>-->
<form action="/exchangeItem" method="post">
<div class="mb-3">
<label class="form-label" for="name">Name:</label>
<input class="form-control" id="name" name="name" placeholder="
Item Name" type="text"/>
</div>
<div class="mb-3">
<label class="form-label" for="description">Description:</label>
<input class="form-control" id="description" name="description"
placeholder="Description" type="text"/>
</div>
<div class="mb-3">
<label class="form-check-label" for="exchangeOrNot">exchangeOrNot?</label>
<input checked="false" class="form-check-input" id="exchangeOrNot"
name="exchangeOrNot" type="checkbox"/>
</div>
<div class="mb-3">
<label class="form-check-label" for="moneyOrNot">moneyOrNot?</label>
<input checked="false" class="form-check-input" id="moneyOrNot"
name="moneyOrNot" type="checkbox"/>
</div>
<div class="mb-3">
<button class="btn btn-primary">Submit</button>
</div>
</form>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -29,5 +29,6 @@ ...@@ -29,5 +29,6 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<a href="/exchange/add"><button>add items</button></a>
</body> </body>
</html> </html>
\ No newline at end of file
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