Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,161 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 :)