Skip to content

Commit 805a136

Browse files
committed
adding model property
1 parent f0d32f7 commit 805a136

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ public String displayAllEvents(Model model) {
2929

3030
//lives and /events/create
3131
@GetMapping("create")
32-
public String renderCreateEventForm(Model model) {
32+
public String displayCreateEventForm(Model model) {
3333
model.addAttribute("title", "Create Event");
3434
return "events/create";
3535
}
3636

3737
@PostMapping("create")
38-
public String createEvent(@RequestParam String eventName) {
39-
events.add(new Event(eventName));
38+
public String processCreateEventForm(@RequestParam String eventName,
39+
@RequestParam String eventDescription) {
40+
events.add(new Event(eventName, eventDescription));
4041
return "redirect:/events";
4142

4243
}

src/main/java/org/launchcode/codingevents/models/Event.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
public 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;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
<input type="text" name="eventName" class="form-control">
1212
</label>
1313
</div>
14+
<div class="form-group">
15+
<label>Description
16+
<input type="text" name="eventDescription" class="form-control">
17+
</label>
18+
</div>
1419
<div class="form-group">
1520
<input type="submit" value="Create Event" class="btn btn-success">
1621
</div>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
<thead>
1414
<tr>
1515
<th>Name</th>
16+
<th>Description</th>
1617
</tr>
1718
</thead>
1819
<tr th:each="event : ${events}">
1920
<td th:text="${event.name}"></td>
21+
<td th:text="${event.description}"></td>
2022
</tr>
2123
</table>
2224

0 commit comments

Comments
 (0)