Skip to content

Commit e61ba09

Browse files
Alternative of template context setting
1 parent 7e5529e commit e61ba09

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/main/java/com/codecool/shop/controller/ProductController.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
2525
ProductDao productDataStore = ProductDaoMem.getInstance();
2626
ProductCategoryDao productCategoryDataStore = ProductCategoryDaoMem.getInstance();
2727

28-
// Map params = new HashMap<>();
29-
// params.put("category", productCategoryDataStore.find(1));
30-
// params.put("products", productDataStore.getBy(productCategoryDataStore.find(1)));
31-
3228
TemplateEngine engine = TemplateEngineUtil.getTemplateEngine(req.getServletContext());
3329
WebContext context = new WebContext(req, resp, req.getServletContext());
3430
context.setVariable("category", productCategoryDataStore.find(1));
3531
context.setVariable("products", productDataStore.getBy(productCategoryDataStore.find(1)));
32+
// // Alternative setting of the template context
33+
// Map<String, Object> params = new HashMap<>();
34+
// params.put("category", productCategoryDataStore.find(1));
35+
// params.put("products", productDataStore.getBy(productCategoryDataStore.find(1)));
36+
// context.setVariables(params);
3637
engine.process("product/index.html", context, resp.getWriter());
3738
}
3839

0 commit comments

Comments
 (0)