コード例 #1
0
 private boolean checkInput() {
   if (StringUtils.isEmpty(advertizeShowPageChoice.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "广告显示页面"));
     return false;
   } else if (StringUtils.isEmpty(showType.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "广告类型"));
     return false;
   } else if (StringUtils.isEmpty(sort.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "排序"));
     return false;
   } else if (StringUtils.isEmpty(validFlg.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "有效"));
     return false;
   } else if (opType.equals("I") && upLinksIcon.getFileUploads().size() == 0) {
     alertError(MessageUtils.getMessage("ERR0017", "图片"));
     return false;
   } else if (opType.equals("I") && upLinksBakIcon.getFileUploads().size() == 0) {
     alertError(MessageUtils.getMessage("ERR0017", "背景图片"));
     return false;
   } else if (StringUtils.isEmpty(linkUrl.getValue())) {
     alertError(MessageUtils.getMessage("ERR0001", "公司网址"));
     return false;
   } else if (!StringUtils.isUrl(linkUrl.getValue())) {
     alertError(MessageUtils.getMessage("ERR0019", "公司网址"));
     return false;
   }
   clearAlert();
   return true;
 }
コード例 #2
0
  protected void form_OnSubmit() {
    if (!checkInput()) {
      return;
    }
    // 业务鉴证
    AdvertizeDto dto = new AdvertizeDto();
    dto.setId(id);
    Map<String, Object> advertizeMap = operationsManageService.getAdvertizeById(dto);
    if (opType.equals("U") && advertizeMap.isEmpty()) {
      alertError(MessageUtils.getMessage("ERR0013", "数据已被删除。"));
      submitBtn.setDisabled(true);
      return;
    }

    // 文件上传
    String linksImgPath = "";
    String linksBakImgPath = "";
    try {
      if (upLinksIcon.getFileUploads().size() > 0) {
        linksImgPath =
            imageDataStoreManager.put(upLinksIcon.getFileName(), upLinksIcon.getInputStream());
      }
      if (upLinksBakIcon.getFileUploads().size() > 0) {
        linksBakImgPath =
            imageDataStoreManager.put(
                upLinksBakIcon.getFileName(), upLinksBakIcon.getInputStream());
      }
    } catch (FWImageDataStoreException e) {
      if (e.getErrorCode().equals("FW004005E")) {
        alertError(e.getMessage());
      } else {
        logger.error("图片上传失败。", e);
        if ("U".equals(opType)) {
          saveOperatorLog(
              Constants.OPERATOR_LOG_U, Constants.OPERATOR_LOG_FAILURE, "广告【" + id + "】编辑失败。");
        } else {
          saveOperatorLog(Constants.OPERATOR_LOG_I, Constants.OPERATOR_LOG_FAILURE, "广告添加失败。");
        }
        alertError(MessageUtils.getMessage("ERR0013", "图片上传失败。"));
      }
      return;
    }
    // 数据登陆
    dto.setAdvertizeShowPageId(advertizeShowPageChoice.getValue());
    dto.setShowType(showType.getValue());
    dto.setSort(sort.getValue());
    dto.setValidFlg(validFlg.getValue());
    dto.setImgPath(linksImgPath);
    dto.setBackgroundImgPath(linksBakImgPath);
    if (linkUrl.getValue().startsWith("http://")) {
      dto.setLinkUrl(linkUrl.getValue());
    } else {
      dto.setLinkUrl("http://" + linkUrl.getValue());
    }
    dto.setUpdUserId(getAdminUser().getOidAdminUserId());
    if (opType.equals("U")) {
      dto.setId(id);
      boolean upd = operationsManageService.updAdvertize(dto);
      if (upd) {
        try {
          if (!StringUtils.isEmpty(linksImgPath)) {
            imageDataStoreManager.delete(ConvUtils.convToString(advertizeMap.get("IMG_PATH")));
            linksIcon.setSrc(imageDataStoreManager.getURL(linksImgPath).replace("\\", "/"));
          }
          if (!StringUtils.isEmpty(linksBakImgPath)) {
            imageDataStoreManager.delete(
                ConvUtils.convToString(advertizeMap.get("BACKGROUND_IMG_PATH")));
            linksBakIcon.setSrc(imageDataStoreManager.getURL(linksBakImgPath).replace("\\", "/"));
          }
        } catch (FWImageDataStoreException e) {
          logger.error("图片删除失败。", e);
        }
        saveOperatorLog(
            Constants.OPERATOR_LOG_U,
            Constants.OPERATOR_LOG_SUCCESS,
            "广告【" + dto.getId() + "】更新成功。");

        submitBtn.setDisabled(true);
        alertSucc(2);
      } else {
        saveOperatorLog(
            Constants.OPERATOR_LOG_U,
            Constants.OPERATOR_LOG_FAILURE,
            "广告【" + dto.getId() + "】更新失败。");
        alertError(MessageUtils.getMessage("ERR0013", "数据可能已被删除。"));
      }
    } else {
      boolean add = operationsManageService.insAdvertize(dto);
      if (add) {
        saveOperatorLog(
            Constants.OPERATOR_LOG_I,
            Constants.OPERATOR_LOG_SUCCESS,
            "广告【"
                + advertizeShowPageChoice.getValue()
                + ','
                + showType.getValue()
                + ','
                + sort.getValue()
                + "】添加成功。");
        linksIcon.setVisible(true);
        linksIcon.setSrc(imageDataStoreManager.getURL(linksImgPath).replace("\\", "/"));
        linksBakIcon.setVisible(true);
        linksBakIcon.setSrc(imageDataStoreManager.getURL(linksBakImgPath).replace("\\", "/"));
        submitBtn.setDisabled(true);
        alertSucc(2);
      } else {
        saveOperatorLog(
            Constants.OPERATOR_LOG_I,
            Constants.OPERATOR_LOG_FAILURE,
            "广告【"
                + advertizeShowPageChoice.getValue()
                + ','
                + showType.getValue()
                + ','
                + sort.getValue()
                + "】添加失败。");
        alertError(MessageUtils.getMessage("ERR0012"));
      }
    }
  }