Prev | Current Page 439 | Next

Frank Zammetti

"Practical DWR 2 Projects"

isDebugEnabled()) {
log.debug("ArticleDAO.getAllArticles() - articles = " + articles);
}
CHAPTER 5 n SHARE YOUR KNOWLEDGE: DWIKI, THE DWR-BASED WIKI 248
Map tokens = new HashMap();
tokens.put("articles", articles);
Article article = getStaticArticle("AllArticlesIndex", tokens);
log.trace("ArticleDAO.getAllArticles() - Exit");
return article;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
} // End getAllArticles().
Only two major steps are required. First, the SQL_GET_ARTICLES query is executed, which
gets us a list of all articles, but only the title, creator, and date/time created for each. Note that
this execution gets us a List of Maps back, because that??™s what the queryForList() method of
the JdbcTemplate class returns. We simply add this List to a Map, which is now the data model
for the FreeMarker template that will generate the output.
getStaticArticle() Method
In order to execute the template, a call is next made to getStaticArticle(), which we??™ll look
at now:
private Article getStaticArticle(final String inTitle, final Map inTokens)
throws Exception {
log.trace("ArticleDAO.getStaticArticle() - Entry");
try {
Article article = new Article();
article.


Pages:
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451