userhandler.java

来自「大名顶顶的JDON的测试程序」· Java 代码 · 共 73 行

JAVA
73
字号
/**
 * Copyright 2005 Jdon.com
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */

package com.jdon.framework.test.web;

import com.jdon.model.*;
import javax.servlet.http.*;
import com.jdon.controller.events.*;
import com.jdon.controller.model.Model;
import com.jdon.controller.WebAppUtil;

import com.jdon.framework.test.ejb.TestEJBLocal;
import org.apache.log4j.Logger;


/**
 *
 *
 * @author <a href="mailto:banqiao@jdon.com">banq</a>
 * @version JdonFramework 2005 v1.0
 */
public class UserHandler extends ModelHandler {
  private final static Logger logger = Logger.getLogger(UserHandler.class);

  public ModelForm initForm(HttpServletRequest request) throws java.lang.
      Exception {
    return new UserActionForm();
  }

  public Model findModelByKey(String keyValue, HttpServletRequest request) throws
      java.lang.Exception {
    logger.debug(" enter find action ...");
    TestEJBLocal testEJB = (TestEJBLocal) WebAppUtil.getEJBService("testEJB",request);
    return testEJB.getUser(keyValue);
  }

  public void serviceAction(EventModel em, HttpServletRequest request) throws
      java.lang.Exception {
    logger.debug(" enter save action ...");
    TestEJBLocal testEJB = (TestEJBLocal) WebAppUtil.getEJBService("testEJB",request);
    logger.debug(" get EJB ok!...");
    try {
      switch (em.getActionType()) {
        case Event.CREATE:
          testEJB.createUser(em);
          break;
        case Event.EDIT:
          testEJB.updateUser(em);
          break;
        case Event.DELETE:
          testEJB.deleteUser(em);
          break;
      }
    } catch (Exception ex) {
      throw new Exception(" serviceAction Error:" + ex);
    }

  }

}

⌨️ 快捷键说明

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