⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subcategoryactions.java

📁 噶额外噶外骨骼感广泛高热感 就 啊啊
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                                  (String) request.getSession().getAttribute("shopID"),
                                  langID);
      request.setAttribute("subcategories", subCategories);
    } catch(CategoryException ex) {
      servlet.log("ListSubCategoryError", ex);    
      ActionErrors errors = new ActionErrors();
      errors.add("ShopError", new ActionError("common.error", ex.getMessage()));
      saveErrors(request, errors);

      return mapping.findForward("error");
    } catch(Exception ex) {
      servlet.log("ListSubCategoryError", ex);    
      ActionErrors errors = new ActionErrors();
      errors.add("ShopError", new ActionError("common.error", ex.getMessage()));
      saveErrors(request, errors);

      return mapping.findForward("error");
    } finally {

      try {

        if(shopBean != null) {
          shopBean.remove();
        }

        if(adminBean != null) {
          adminBean.remove();
        }
      } catch(Exception ex) {
      }
    }

    return forward;
  }
  /**
   * This is the action called from the Struts framework to get the
   * subcategory information
   *
   * @param mapping The ActionMapping used to select this instance.
   * @param form The optional ActionForm bean for this request.
   * @param request The HTTP Request we are processing.
   * @param response The HTTP Response we are processing.
   */
  public ActionForward editSubCategoryForm(
                                           ActionMapping mapping,
                                           ActionForm form,
                                           HttpServletRequest request,
                                           HttpServletResponse response)
                                    throws IOException, 
                                           ServletException {

    ShopOwnerHome shopHome = null;
    ShopOwner shopBean     = null;
    ActionForward forward  = mapping.findForward("editSubCategoryForm");

    try {

      String langID = request.getLocale().getLanguage();
      shopHome =
        (ShopOwnerHome) ServiceLocator.getLocator().getService("ShopOwner");
      shopBean = shopHome.create();

      SubCategory subCategory =
        shopBean.getSubCategory(
                                (String) request.getParameter("subCategory"),
                                langID);
      request.setAttribute("subcategory", subCategory);
    } catch(CategoryException ex) {
      servlet.log("EditSubCategoryFormError", ex);    
      ActionErrors errors = new ActionErrors();
      errors.add("ShopError", new ActionError("common.error", ex.getMessage()));
      saveErrors(request, errors);

      return mapping.findForward("error");
    } catch(Exception ex) {
      servlet.log("EditSubCategoryFormError", ex);    
      ActionErrors errors = new ActionErrors();
      errors.add("ShopError", new ActionError("common.error", ex.getMessage()));
      saveErrors(request, errors);

      return mapping.findForward("error");
    } finally {

      try {

        if(shopBean != null) {
          shopBean.remove();
        }
      } catch(Exception ex) {
      }
    }

    return forward;
  }
  /**
   * This is the action called from the Struts framework to update the
   * subcategory information
   *
   * @param mapping The ActionMapping used to select this instance.
   * @param form The optional ActionForm bean for this request.
   * @param request The HTTP Request we are processing.
   * @param response The HTTP Response we are processing.
   */
  public ActionForward editSubCategory(
                                       ActionMapping mapping, ActionForm form,
                                       HttpServletRequest request,
                                       HttpServletResponse response)
                                throws IOException, 
                                       ServletException {

    ShopOwnerHome shopHome = null;
    ShopOwner shopBean     = null;
    ActionForward forward  = mapping.findForward("success");

    try {

      String langID = request.getLocale().getLanguage();
      String shopID = (String) request.getSession().getAttribute("shopID");
      shopHome =
        (ShopOwnerHome) ServiceLocator.getLocator().getService("ShopOwner");
      shopBean      = shopHome.create();

      // Construct a value object to pass subcategory information to the 
      // subcategory service
      shopBean.updateSubCategory(new SubCategory(
                                                 (String) request.getParameter("subCatID"),
                                                 shopID,
                                                 (String) request.getParameter("subCatName"),
                                                 null, langID));
      request.setAttribute(
                           "message",
                           MessageCache.getMessage(
                                                   "message.editsubcat.success",
                                                   getLocale(request)));

    } catch(CategoryException ex) {
      servlet.log("EditSubCategoryError", ex);        
      request.setAttribute(
                           "message",
                           MessageCache.getMessage(
                                                   ex.getMessageCode(),
                                                   getLocale(request)));

      SubCategory subCategory =
        new SubCategory(
                        request.getParameter("subCatID"), null,
                        request.getParameter("subCatName"), null, null);
      request.setAttribute("subcategory", subCategory);
      forward = mapping.findForward("editSubCategoryForm");
    } catch(Exception ex) {
      servlet.log("EditSubCategoryForm", ex);    
      ActionErrors errors = new ActionErrors();
      errors.add("ShopError", new ActionError("common.error", ex.getMessage()));
      saveErrors(request, errors);

      return mapping.findForward("error");
    } finally {

      try {

        if(shopBean != null) {
          shopBean.remove();
        }
      } catch(Exception ex) {
      }
    }

    return forward;
  }
  /**
   * This is the action called from the Struts framework to delete a
   * subcategory
   *
   * @param mapping The ActionMapping used to select this instance.
   * @param form The optional ActionForm bean for this request.
   * @param request The HTTP Request we are processing.
   * @param response The HTTP Response we are processing.
   */
  public ActionForward deleteSubCategory(
                                         ActionMapping mapping, ActionForm form,
                                         HttpServletRequest request,
                                         HttpServletResponse response)
                                  throws IOException, 
                                         ServletException {

    ShopOwnerHome shopHome = null;
    ShopOwner shopBean     = null;
    ActionForward forward  = mapping.findForward("success");

    try {

      String langID = request.getLocale().getLanguage();
      shopHome =
        (ShopOwnerHome) ServiceLocator.getLocator().getService("ShopOwner");
      shopBean = shopHome.create();

      String[] subCatIDs = (String[]) request.getParameterValues("subCatID");

      for(int i = 0; i < subCatIDs.length; i++) {
        shopBean.deleteSubCategory(
                                   subCatIDs [ i ],
                                   (String) request.getSession().getAttribute("shopID"));
      }

      request.setAttribute(
                           "message",
                           MessageCache.getMessage(
                                                   "message.deletesubcat.success",
                                                   getLocale(request)));

    } catch(CategoryException ex) {
      servlet.log("DeleteSubCategoryError", ex);        
      request.setAttribute(
                           "message",
                           MessageCache.getMessage(
                                                   ex.getMessageCode(),
                                                   getLocale(request)));
      forward = mapping.findForward("manageSubCatForm");
    } catch(Exception ex) {
      servlet.log("DeleteSubCategoryError", ex);
      ActionErrors errors = new ActionErrors();
      errors.add("ShopError", new ActionError("common.error", ex.getMessage()));
      saveErrors(request, errors);

      return mapping.findForward("error");
    } finally {

      try {

        if(shopBean != null) {
          shopBean.remove();
        }
      } catch(Exception ex) {
      }
    }

    return forward;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -