Пример #1
0
 /**
  * 更新功能
  *
  * @return
  */
 public String update() {
   try {
     // 1. 检查传入的会员等级属性是否合法
     if (!checkCategoryVO()) {
       return ERROR;
     } else {
       // 2. 更新新的会员等级
       categoryService.updateCategory(category);
       setMessage(MessageUtil.getMessage("category_update_success", category.getName()));
       category = new CategoryVO();
     }
   } catch (DuplicateNameException e) {
     this.setMessage(e.getMessage());
     return ERROR;
   } catch (CategoryNotFoundException e) {
     this.setMessage(e.getMessage());
     return ERROR;
   } catch (NumberFormatException e) {
     this.setMessage(e.getMessage());
     return ERROR;
   } finally {
     getCategoryList();
     refreshPageData();
   }
   return SUCCESS;
 }
Пример #2
0
  /**
   * 添加新会员等级Action
   *
   * @return
   */
  public String save() {
    logger.debug(category);
    try {
      // 1. 检查传入的会员等级属性是否合法
      if (!checkCategoryVO()) {
        return ERROR;
      } else {
        // 2. 创建新的会员等级
        categoryService.addCategory(category);
        setMessage(MessageUtil.getMessage("category_save_success", category.getName()));
        category = new CategoryVO();
      }
    } catch (DuplicateNameException e) {
      logger.error(e.getMessage());
      this.setMessage(e.getMessage());
      return ERROR;
    } finally {
      getCategoryList();
      refreshPageData();
    }

    return SUCCESS;
  }