File tree Expand file tree Collapse file tree
Spring Boot/codingevents/src/main
java/org/launchcode/codingevents
resources/templates/events Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,20 +19,22 @@ public class EventController {
1919
2020 @ GetMapping
2121 public String displayAllEvents (Model model ) {
22+ model .addAttribute ("title" , "All Events" );
2223 model .addAttribute ("events" , events );
2324 return "events/index" ;
2425 }
2526
2627 // lives at /events/create
2728 @ GetMapping ("create" )
28- public String renderCreateEventForm () {
29+ public String displayCreateEventForm (Model model ) {
30+ model .addAttribute ("title" , "Create Event" );
2931 return "events/create" ;
3032 }
3133
3234 // lives at /events/create
3335 @ PostMapping ("create" )
34- public String createEvent (@ RequestParam String eventName ) {
35- events .add (new Event (eventName ));
36+ public String processCreateEventForm (@ RequestParam String eventName , @ RequestParam String eventDescription ) {
37+ events .add (new Event (eventName , eventDescription ));
3638 return "redirect:/events" ;
3739 }
3840
Original file line number Diff line number Diff line change 33public class Event {
44
55 private String name ;
6+ private String description ;
67
7- public Event (String name ) {
8+ public Event (String name , String description ) {
89 this .name = name ;
10+ this .description = description ;
911 }
1012
1113 public String getName () {
@@ -16,6 +18,14 @@ public void setName(String name) {
1618 this .name = name ;
1719 }
1820
21+ public String getDescription () {
22+ return description ;
23+ }
24+
25+ public void setDescription (String description ) {
26+ this .description = description ;
27+ }
28+
1929 @ Override
2030 public String toString () {
2131 return name ;
Original file line number Diff line number Diff line change @@ -9,10 +9,15 @@ <h1>Create Event</h1>
99
1010< form method ="post ">
1111 < div class ="form-group ">
12- < label >
12+ < label > Name
1313 < input type ="text " name ="eventName " class ="form-control ">
1414 </ label >
1515 </ div >
16+ < div class ="form-group ">
17+ < label > Description
18+ < input type ="text " name ="eventDescription " class ="form-control ">
19+ </ label >
20+ </ div >
1621 < div class ="form-group ">
1722 < input type ="submit " value ="Create " class ="btn btn-success ">
1823 </ div >
Original file line number Diff line number Diff line change @@ -10,11 +10,13 @@ <h1>All Events</h1>
1010< table class ="table table-striped ">
1111 < thead >
1212 < tr >
13- < th > NAME</ th >
13+ < th > Name</ th >
14+ < th > Description</ th >
1415 </ tr >
1516 </ thead >
1617 < tr th:each ="event : ${events} ">
1718 < td th:text ="${event.name} "> </ td >
19+ < td th:text ="${event.description} "> </ td >
1820 </ tr >
1921</ table >
2022
You can’t perform that action at this time.
0 commit comments