Example #1
0
 // 保存
 @Validations(
     requiredStrings = {
       @RequiredStringValidator(fieldName = "friendLink.name", message = "友情链接名称不允许为空!"),
       @RequiredStringValidator(fieldName = "friendLink.url", message = "链接地址不允许为空!")
     },
     intRangeFields = {
       @IntRangeFieldValidator(
           fieldName = "friendLink.orderList",
           min = "0",
           message = "排序必须为零或正整数!")
     })
 @InputConfig(resultName = "error")
 public String save() throws Exception {
   if (logo != null) {
     String logoPath = ImageUtil.copyImageFile(getServletContext(), logo);
     friendLink.setLogoPath(logoPath);
   } else {
     friendLink.setLogoPath(null);
   }
   friendLinkService.save(friendLink);
   redirectUrl = "friend_link!list.action";
   return SUCCESS;
 }
Example #2
0
 // 更新
 @Validations(
     requiredStrings = {
       @RequiredStringValidator(fieldName = "friendLink.name", message = "友情链接名称不允许为空!"),
       @RequiredStringValidator(fieldName = "friendLink.url", message = "链接地址不允许为空!")
     },
     intRangeFields = {
       @IntRangeFieldValidator(
           fieldName = "friendLink.orderList",
           min = "0",
           message = "排序必须为零或正整数!")
     })
 @InputConfig(resultName = "error")
 public String update() throws Exception {
   FriendLink persistent = friendLinkService.load(id);
   if (logo != null) {
     String logoPath = ImageUtil.copyImageFile(getServletContext(), logo);
     persistent.setLogoPath(logoPath);
   }
   BeanUtils.copyProperties(
       friendLink, persistent, new String[] {"id", "createDate", "modifyDate", "logoPath"});
   friendLinkService.update(persistent);
   redirectUrl = "friend_link!list.action";
   return SUCCESS;
 }