Ejemplo n.º 1
0
 private WebErrors validateSave(CmsModelItem bean, Integer modelId, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (!StringUtils.isBlank(bean.getOptValue())) {
     bean.setOptValue(replaceLocaleSplit(bean.getOptValue(), request));
   }
   return errors;
 }
Ejemplo n.º 2
0
  private List<CmsModelItem> getItems(
      CmsModel model,
      boolean isChannel,
      String[] fields,
      String[] labels,
      Integer[] dataTypes,
      Integer[] prioritys,
      Boolean[] singles,
      Boolean[] displays) {
    List<CmsModelItem> list = new ArrayList<CmsModelItem>();
    CmsModelItem item;
    for (int i = 0, len = fields.length; i < len; i++) {
      if (!StringUtils.isBlank(fields[i])) {
        item = new CmsModelItem();
        item.setCustom(false);
        item.setModel(model);
        item.setChannel(isChannel);

        item.setField(fields[i]);
        item.setLabel(labels[i]);
        item.setPriority(prioritys[i]);
        item.setDataType(dataTypes[i]);
        item.setSingle(singles[i]);
        item.setDisplay(displays[i]);

        list.add(item);
      }
    }
    return list;
  }
Ejemplo n.º 3
0
 private List<String> getFieldList(List<CmsModelItem> items) {
   List<String> list = new ArrayList<String>(items.size());
   for (CmsModelItem item : items) {
     list.add(item.getField());
   }
   return list;
 }
Ejemplo n.º 4
0
 private WebErrors validateUpdate(Integer id, CmsModelItem bean, HttpServletRequest request) {
   WebErrors errors = WebErrors.create(request);
   if (!StringUtils.isBlank(bean.getOptValue())) {
     bean.setOptValue(replaceLocaleSplit(bean.getOptValue(), request));
   }
   if (vldExist(id, errors)) {
     return errors;
   }
   return errors;
 }
Ejemplo n.º 5
0
 @RequestMapping("/item/o_update.do")
 public String update(CmsModelItem bean, HttpServletRequest request, ModelMap model) {
   WebErrors errors = validateUpdate(bean.getId(), bean, request);
   if (errors.hasErrors()) {
     return errors.showErrorPage(model);
   }
   bean = manager.update(bean);
   log.info("update CmsModelItem id={}.", bean.getId());
   model.addAttribute("modelId", bean.getModel().getId());
   model.addAttribute("isChannel", bean.getChannel());
   return "redirect:v_list.do";
 }
Ejemplo n.º 6
0
 @RequestMapping("/item/o_delete.do")
 public String delete(
     Integer[] ids,
     Integer modelId,
     Boolean isChannel,
     HttpServletRequest request,
     ModelMap model) {
   WebErrors errors = validateDelete(ids, request);
   if (errors.hasErrors()) {
     return errors.showErrorPage(model);
   }
   CmsModelItem[] beans = manager.deleteByIds(ids);
   for (CmsModelItem bean : beans) {
     log.info("delete CmsModelItem id={}", bean.getId());
   }
   model.addAttribute("modelId", modelId);
   model.addAttribute("isChannel", isChannel);
   return "redirect:v_list.do";
 }