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

📄 itemattrshandler.java

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

import com.jdon.strutsutil.ModelHandler;
import com.jdon.strutsutil.ModelForm;
import javax.servlet.http.HttpServletRequest;
import com.jdon.controller.model.Model;
import com.jdon.controller.events.EventModel;

import com.jdon.controller.events.Event;

import com.jdon.estore.catalog.ProductManagerLocal;
import com.jdon.estore.FrameworkServices;
import com.jdon.bussinessproxy.ServiceServerFactory;
import com.jdon.bussinessproxy.EJBDefinition;

public class ItemAttrsHandler implements ModelHandler {
  private final static String module = ItemAttrsHandler.class.getName();
  private final static ServiceServerFactory sf = ServiceServerFactory.
      getInstance();

  public ModelForm initForm(HttpServletRequest request) throws java.lang.
      Exception {
    AttributeForm form = new AttributeForm();
    String Id = request.getParameter("itemId");
    if ( (Id == null) || (Id.length() == 0))
      throw new Exception("must supply itemId in jsp");
    form.setItemId(Id);

    return form;
  }

  public Model findModelByKey(String keyValue, HttpServletRequest request) throws
      java.lang.Exception {
    ProductManagerLocal productManager = (ProductManagerLocal) sf.getService(
        FrameworkServices.ProductEJB, request);

    return productManager.getItemAttrsById(keyValue);

  }

  public void serviceAction(EventModel em, HttpServletRequest request) throws
      java.lang.Exception {
    ProductManagerLocal productManager = (ProductManagerLocal) sf.getService(
        FrameworkServices.ProductEJB, request);

    try {
      switch (em.getActionType()) {
        case Event.CREATE:
          productManager.createAttrs(em);
          break;
        case Event.EDIT:
          productManager.updateAttrs(em);
          break;
        case Event.DELETE:
          productManager.deleteAttrs(em);
          break;
      }
    } catch (Exception ex) {
      throw new Exception("System operation Error:" + ex);
    }
  }

}

⌨️ 快捷键说明

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