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

📄 categoryhandler.java

📁 使用EJB实现的网上商城
💻 JAVA
字号:
package com.jdon.estore.web.catalog;

import com.jdon.strutsutil.*;

import javax.servlet.http.HttpServletRequest;
import com.jdon.bussinessproxy.ServiceServerFactory;
import com.jdon.bussinessproxy.EJBDefinition;

import com.jdon.controller.model.Model;
import com.jdon.controller.events.*;

import com.jdon.estore.model.Category;

import com.jdon.estore.catalog.CatalogManagerLocal;
import com.jdon.estore.FrameworkServices;

public class CategoryHandler implements ModelHandler {

  private final static ServiceServerFactory sf = ServiceServerFactory.
      getInstance();


  public ModelForm initForm(HttpServletRequest request) throws Exception{
    return new CategoryForm();
  }

  public Model findModelByKey(String keyValue, HttpServletRequest request) throws Exception{

    CatalogManagerLocal catalogManager = (CatalogManagerLocal) sf.getService(
        FrameworkServices.CatalogEJB, request);
    return catalogManager.getCategoryById(keyValue);
  }

  public void serviceAction(EventModel em, HttpServletRequest request) throws
      java.lang.
      Exception {
    CatalogManagerLocal catalogManager = (CatalogManagerLocal) sf.getService(
        FrameworkServices.CatalogEJB, request);
    try {
      switch (em.getActionType()) {
        case Event.CREATE:
          catalogManager.createCategory(em);
          break;
        case Event.EDIT:
          catalogManager.updateCategory(em);
          break;
        case Event.DELETE:
          catalogManager.deleteCategory(em);
          break;
      }
    } catch (Exception ex) {
      throw new Exception("System operation Error:" + ex);
    }
  }

}

⌨️ 快捷键说明

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