示例#1
0
  @RequestMapping(value = "/vote/{id}.jspx")
  public String view(
      @PathVariable("id") Integer id,
      HttpServletRequest request,
      HttpServletResponse response,
      org.springframework.ui.Model modelMap) {
    Response resp = new Response(request, response, modelMap);
    List<String> messages = resp.getMessages();
    Vote vote = service.get(id);
    if (!Validations.exist(vote, messages, "Vote", id)) {
      return resp.notFound();
    }

    Site currSite = Context.getCurrentSite(request);
    modelMap.addAttribute("vote", vote);
    Map<String, Object> data = modelMap.asMap();
    ForeContext.setData(data, request);
    return currSite.getTemplate(VIEW_TEMPLATE);
  }
示例#2
0
  @RequestMapping(value = "/vote.jspx")
  public String form(
      Integer id,
      HttpServletRequest request,
      HttpServletResponse response,
      org.springframework.ui.Model modelMap) {
    Response resp = new Response(request, response, modelMap);
    List<String> messages = resp.getMessages();
    if (!Validations.notNull(id, messages, "id")) {
      return resp.badRequest();
    }
    Vote vote = service.get(id);
    if (!Validations.exist(vote, messages, "Vote", id)) {
      return resp.notFound();
    }

    modelMap.addAttribute("vote", vote);
    Site site = Context.getCurrentSite(request);
    Map<String, Object> data = modelMap.asMap();
    ForeContext.setData(data, request);
    return site.getTemplate(TEMPLATE);
  }