Ejemplo n.º 1
0
 @RequestMapping(value = "/add/{id}", method = RequestMethod.POST)
 public String add(
     @PathVariable Integer id, @Valid DataDTO dataDTO, BindingResult br, Model model) {
   if (br.hasErrors()) {
     model.addAttribute(caseService.getCaseBean(id));
     return "data/add";
   }
   CaseBean caseBean = new CaseBean();
   DataBean dataBean = new DataBean();
   caseBean.setId(dataDTO.getCaseId());
   dataBean.setCaseBean(caseBean);
   dataBean.setDataContent(dataDTO.getDataContent());
   dataBean.setDataName(dataDTO.getDataName());
   dataService.addData(dataBean);
   return "redirect:/data/list/" + dataDTO.getCaseId();
 }
Ejemplo n.º 2
0
 @RequestMapping(value = "/update/{cid}/{id}", method = RequestMethod.POST)
 public String update(
     @PathVariable Integer cid,
     @PathVariable Integer id,
     @Valid DataDTO dataDTO,
     BindingResult br,
     Model model) {
   if (br.hasErrors()) {
     model.addAttribute(caseService.getCaseBean(cid));
     return "data/edit";
   }
   DataBean dataBean = dataService.getData(id);
   dataBean.setDataContent(dataDTO.getDataContent());
   dataBean.setDataName(dataDTO.getDataName());
   dataService.updateData(dataBean);
   return "redirect:/data/list/" + cid;
 }