Skip to content

Instantly share code, notes, and snippets.

@taywils
Last active December 28, 2015 09:39
Show Gist options
  • Save taywils/7480416 to your computer and use it in GitHub Desktop.
Save taywils/7480416 to your computer and use it in GitHub Desktop.
spark_view_step_2_1
get(new FreeMarkerRoute("/") {
@Override
public ModelAndView handle(Request request, Response response) {
Map<String, Object> viewObjects = new HashMap<String, Object>();
if(HelloSpark.articles.isEmpty()) {
viewObjects.put("hasNoArticles", "Welcome, please click \"Write Article\" to begin.");
} else {
ArrayList<Article> showArticles = new ArrayList<Article>();
for(Article article : HelloSpark.articles) {
if(article.readable()) {
showArticles.add(article);
}
}
viewObjects.put("articles", showArticles);
}
viewObjects.put("templateName", "articleList.ftl");
return modelAndView(viewObjects, "layout.ftl");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment