Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Intro to Java Web Development with Spark Bells and Whistles Adding to and Iterating a List

Martin Torres
Martin Torres
10,353 Points

My ideas doesn't show

I checked my code and it's very similar to Craig's code, i don't know why it doesn't show the list of ideas

get("/ideas",(req,res) -> { Map<String,Object> model = new HashMap<>(); model.put("idea",dao.findAll()); return new ModelAndView(model,"ideas.hbs"); }, new HandlebarsTemplateEngine());

post("/ideas",(req,res) ->{ String title = req.queryParams("title"); CourseIdea courseIdea = new CourseIdea(title,req.cookie("username")); dao.add(courseIdea); res.redirect("/ideas"); return null; });

{{#partial "content"}} <h1>Current ideas</h1>

<ul>
    {{#each ideas}}
        <li>{{ title }}</li>
    {{/each}}
</ul>

<form action="/ideas" method="post">
    <input type="text" placeholder="What's your idea?" name="title">
    <button>Suggest!</button>
</form>

{{/partial}} {{> base.hbs}}

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Here is Craigs code chunk

        get("/ideas", (req, res) -> {
            Map<String, Object> model = new HashMap<>();
            //omiited code
            model.put("ideas", dao.findAll());
            // omitted code
            return new ModelAndView(model, "ideas.hbs");
        }, new HandlebarsTemplateEngine());

And here is yours

get("/ideas",(req,res) -> { 
  Map<String,Object> model = new HashMap<>(); 
  model.put("idea",dao.findAll()); 
  return new ModelAndView(model,"ideas.hbs"); 
}, new HandlebarsTemplateEngine());

Do you see the difference?

Martin Torres
Martin Torres
10,353 Points

Now I see, thank you, I feel a little silly now that I saw my error. I appreciate your help :)