Skip to content

Commit 00086bb

Browse files
committed
create-model branch complete
1 parent 5e445b8 commit 00086bb

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

src/main/java/org/launchcode/codingevents/controllers/EventController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.launchcode.codingevents.controllers;
22

3+
import org.launchcode.codingevents.models.Event;
34
import org.springframework.stereotype.Controller;
45
import org.springframework.web.bind.annotation.GetMapping;
56
import org.springframework.web.bind.annotation.PostMapping;
@@ -17,7 +18,7 @@
1718
@RequestMapping("events")
1819
public 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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
}

src/main/resources/templates/events/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
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

0 commit comments

Comments
 (0)