File tree Expand file tree Collapse file tree
java/org/launchcode/kodingevents/controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import org .springframework .web .bind .annotation .RequestParam ;
99
1010import java .util .ArrayList ;
11+ import java .util .HashMap ;
1112import java .util .List ;
1213
1314/**
1718@ RequestMapping ("events" )
1819public class EventController {
1920
20- private static List <String > events = new ArrayList <>();
21+ private static HashMap <String , String > events = new HashMap <>();
2122
2223 @ GetMapping
2324 public String displayAllEvents (Model model ) {
25+ events .put ("Menteaship" ,"A fun meetup for connecting with mentors" );
26+ events .put ("Code With Pride" ,"A fun meetup sponsored by LaunchCode" );
27+ events .put ("Javascripty" , "An imaginary meetup for Javascript developers" );
28+
2429 model .addAttribute ("title" , "all Events" );
2530 model .addAttribute ("events" , events );
2631 return "events/index" ;
@@ -32,8 +37,8 @@ public String renderCreateEvenForm() {
3237 return "events/create" ;
3338 }
3439 @ PostMapping ("create" )
35- public String createEvent (@ RequestParam String eventName ) {
36- events .add (eventName );
40+ public String createEvent (@ RequestParam String eventName , String eventDescription ) {
41+ events .put (eventName , eventDescription );
3742 return "redirect:/events" ;
3843 }
3944
Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ <h1>Create Event</h1>
1111 < label > Name
1212 < input type ="text " name ="eventName " class ="form-control ">
1313 </ label >
14+
15+ < label > Description
16+ < input type ="text " name ="eventDescription " class ="form-control ">
17+ </ label >
1418 </ div >
1519 < div class ="form=group ">
1620 < input type ="submit " value ="Create Event " class ="btn btn-success ">
Original file line number Diff line number Diff line change @@ -13,10 +13,14 @@ <h1>All Events</h1>
1313 < thead >
1414 < Tr >
1515 < th > Name</ th >
16+ < th > Description</ th >
17+ < th > Location</ th >
1618 </ Tr >
1719 </ thead >
1820 < tr th:each ="event : ${events} ">
19- < td th:text ="${event} "> </ td >
21+ < td th:text ="${event.key} "> </ td >
22+ < td th:text ="${event.value} "> </ td >
23+ < td th:replace ="fragments :: address "> </ td >
2024 </ tr >
2125 </ table >
2226
Original file line number Diff line number Diff line change 1111< body >
1212
1313< nav th:fragment ="navigation ">
14+ < h1 th:text ="${title} "> Coding Events</ h1 >
1415 < ul class ="nav ">
1516 < li class ="nav-item "> < a class ="nav-link " href ="/events "> All Events</ a > </ li >
1617 < li class ="nav-item "> < a class ="nav-link " href ="/events/create "> Create Event</ a > </ li >
1718 </ ul >
1819</ nav >
1920
21+ < td th:fragment ="address "> 1234 5th Street</ td >
22+
2023</ body >
2124</ html >
You can’t perform that action at this time.
0 commit comments