File tree Expand file tree Collapse file tree
java/org/launchcode/codingevents
resources/templates/events Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .launchcode .codingevents .controllers ;
22
3+ import org .launchcode .codingevents .models .Event ;
34import org .springframework .stereotype .Controller ;
45import org .springframework .web .bind .annotation .GetMapping ;
56import org .springframework .web .bind .annotation .PostMapping ;
1718@ RequestMapping ("events" )
1819public class EventController {
1920
20- private static List <String > events = new ArrayList <>();
21+ private static List <Event > events = new ArrayList <>();
2122
2223 @ GetMapping
2324 public String displayAllEvents (Model model ) {
@@ -34,7 +35,7 @@ public String displayCreateEventForm(Model model) {
3435
3536 @ PostMapping ("create" )
3637 public String processCreateEventForm (@ RequestParam String eventName ) {
37- events .add (eventName );
38+ events .add (new Event ( eventName ) );
3839 return "redirect:/events" ;
3940 }
4041
Original file line number Diff line number Diff line change 1+ package org .launchcode .codingevents .models ;
2+
3+ /**
4+ * Created by Chris Bay
5+ */
6+ public class Event {
7+
8+ private String name ;
9+
10+ public Event (String name ) {
11+ this .name = name ;
12+ }
13+
14+ public String getName () {
15+ return name ;
16+ }
17+
18+ public void setName (String name ) {
19+ this .name = name ;
20+ }
21+
22+ @ Override
23+ public String toString () {
24+ return name ;
25+ }
26+
27+ }
Original file line number Diff line number Diff line change 1212 </ tr >
1313 </ thead >
1414 < tr th:each ="event : ${events} ">
15- < td th:text ="${event} "> </ td >
15+ < td th:text ="${event.name } "> </ td >
1616 </ tr >
1717</ table >
1818
You can’t perform that action at this time.
0 commit comments