Skip to content

Commit 9b219da

Browse files
committed
add-property branch complete
1 parent 00086bb commit 9b219da

4 files changed

Lines changed: 28 additions & 8 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
@@ -34,8 +34,9 @@ public String displayCreateEventForm(Model model) {
3434
}
3535

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

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
package org.launchcode.codingevents.models;
22

3+
import java.util.Objects;
4+
35
/**
46
* Created by Chris Bay
57
*/
68
public class Event {
79

810
private String name;
11+
private String description;
912

10-
public Event(String name) {
13+
public Event(String name, String description) {
1114
this.name = name;
15+
this.description = description;
1216
}
1317

1418
public String getName() {
@@ -19,6 +23,14 @@ public void setName(String name) {
1923
this.name = name;
2024
}
2125

26+
public String getDescription() {
27+
return description;
28+
}
29+
30+
public void setDescription(String description) {
31+
this.description = description;
32+
}
33+
2234
@Override
2335
public String toString() {
2436
return name;

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@
55

66
<header th:replace="fragments :: header"></header>
77

8+
89
<form method="post">
910
<div class="form-group">
10-
<label> Name
11+
<label>Name
1112
<input type="text" name="eventName" class="form-control">
1213
</label>
1314
</div>
14-
<br>
15+
<div class="form-group">
16+
<label>Description
17+
<input type="text" name="eventDescription" class="form-control">
18+
</label>
19+
</div>
1520
<div class="form-group">
1621
<input type="submit" value="Create" class="btn btn-success">
1722
</div>

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77

88
<table class="table table-striped">
99
<thead>
10-
<tr>
11-
<th>Name</th>
12-
</tr>
10+
<tr>
11+
<th>Name</th>
12+
<th>Description</th>
13+
</tr>
1314
</thead>
1415
<tr th:each="event : ${events}">
1516
<td th:text="${event.name}"></td>
17+
<td th:text="${event.description}"></td>
1618
</tr>
1719
</table>
1820

0 commit comments

Comments
 (0)