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

📄 logsupvendoraction.java

📁 一个关于tlms的一个小程序 看看能否帮助到别人
💻 JAVA
字号:
/**
 * =============================================
 * Copyright 2006 szmx
 *
 * Change Revision
 * --------------------------------
 *   Date          Author      Remarks
 *   2006-4-20      terry.zhang    Create com.szmx.tlms.supplychain.web.LogSupVendorAction
 * =============================================
 */

package com.szmx.tlms.supplychain.web;

import com.szmx.framework.base.web.BaseAction;
import com.szmx.framework.base.model.Pagination;
import com.szmx.tlms.TlmsServiceException;
import com.szmx.tlms.GlobalConstants;
import com.szmx.tlms.supplychain.service.LogSupVendorService;
import com.szmx.tlms.supplychain.model.LogSupVendor;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.DynaActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author terry.zhang
 * @since 2006-4-20
 */

public class LogSupVendorAction extends BaseAction {
    /**
     * 
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward searchLogSupVendorInfo(ActionMapping mapping, ActionForm form,
                                            HttpServletRequest request,
                                            HttpServletResponse response)
            throws Exception {

        if (log.isDebugEnabled()) {
            log.debug("Entering 'searchLogSupVendorInfo' method");
        }

        LogSupVendorService logSupVendorService = (LogSupVendorService) getBean("logSupVendorService");
        DynaActionForm dynaForm = (DynaActionForm) form;
        Pagination pageObj = new Pagination(request, "row");
        LogSupVendor logSupVendor= (LogSupVendor)dynaForm.get("searchBean");
        logSupVendor.check();//to check the LogSupVendor's name wheather are empty or null
        Pagination pagination = logSupVendorService.getLogSupVendors(pageObj,logSupVendor);
        request.setAttribute("pagination", pagination);

       return mapping.findForward("success");
    }

    /**
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward initUpdateLogSupVendor(ActionMapping mapping, ActionForm form,
                                            HttpServletRequest request,
                                            HttpServletResponse response)
    throws Exception {
        if (log.isDebugEnabled()) {
            log.debug("Entering 'edit' method");
        }

        DynaActionForm dynaForm = (DynaActionForm) form;
        LogSupVendor logSupVendor = (LogSupVendor) dynaForm.get("logSupVendorBean");
        LogSupVendorService logSupVendorService = (LogSupVendorService) getBean("logSupVendorService");

        try {
            logSupVendor = logSupVendorService.getLogSupVendor(logSupVendor.getId().toString());
        } catch (TlmsServiceException e) {
            saveActionErrorMessage(request, GlobalConstants.COMMON_MESSAGE_UPDATE_FAIL, null);
            throw e;
        }

        if (logSupVendor == null) {
            saveActionErrorMessage(request, "err.supplychain.logSupVendor.get.noExisted", null);
            return mapping.findForward("failure");
        }
        dynaForm.set("logSupVendorBean", logSupVendor);
        return mapping.findForward("success");
    }

    /**
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward updateLogSupVendor(ActionMapping mapping, ActionForm form,
                                        HttpServletRequest request,
                                        HttpServletResponse response)
            throws Exception {
        if (log.isDebugEnabled()) {

            log.debug("Entering 'updateLogSupVendor' method");
        }

        DynaActionForm dynaForm = (DynaActionForm) form;
        LogSupVendor logSupVendor = (LogSupVendor) dynaForm.get("logSupVendorBean");

        logSupVendor.populateUpdateBean(new Long(1111));//todo

        LogSupVendorService logSupVendorService = (LogSupVendorService) getBean("logSupVendorService");

        try {
            logSupVendorService.saveLogSupVendor(logSupVendor);
            dynaForm.set("logSupVendorBean", logSupVendor);
            request.setAttribute("logSupVendorBean", logSupVendor);
        } catch (TlmsServiceException e) {
            request.setAttribute("logSupVendorBean", logSupVendor);
            saveActionErrorMessage(request, GlobalConstants.COMMON_MESSAGE_UPDATE_FAIL, null);
            throw e;
        }

        saveActionTripMessage(request, "message.update", null);

        return mapping.findForward("success");
    }

    /**
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward initAddLogSupVendor(ActionMapping mapping, ActionForm form,
                                         HttpServletRequest request,
                                         HttpServletResponse response)
            throws Exception {
        if (log.isDebugEnabled()) {

            log.debug("Entering 'initAddLogSupVendor' method");
        }

        LogSupVendor logSupVendor = new LogSupVendor();
        request.setAttribute("logSupVendorBean", logSupVendor);

        return mapping.findForward("success");
    }

    /**
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward addLogSupVendor(ActionMapping mapping, ActionForm form,
                                     HttpServletRequest request,
                                     HttpServletResponse response)
            throws Exception {
        if (log.isDebugEnabled()) {

            log.debug("Entering 'addLogSupVendor' method");
        }

        DynaActionForm dynaForm = (DynaActionForm) form;
        LogSupVendor logSupVendor = (LogSupVendor) dynaForm.get("logSupVendorBean");
        logSupVendor.populateCreateBean(new Long(1010));//todo


        LogSupVendorService logSupVendorService = (LogSupVendorService) getBean("logSupVendorService");

        try {
            logSupVendorService.saveLogSupVendor(logSupVendor);
            dynaForm.set("logSupVendorBean", logSupVendor);
            request.setAttribute("logSupVendorBean", logSupVendor);
        } catch (TlmsServiceException e) {
            saveActionErrorMessage(request, GlobalConstants.COMMON_MESSAGE_ADD_FAIL, null);
            throw e;
        }

        saveActionTripMessage(request,"message.add", null);

        return mapping.findForward("success");
    }

    /**
     *
     * @param mapping
     * @param form
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ActionForward removeLogSupVendor(ActionMapping mapping, ActionForm form,
                                        HttpServletRequest request,
                                        HttpServletResponse response)
            throws Exception {
        if (log.isDebugEnabled()) {

            log.debug("Entering 'removeLogSupVendor' method");
        }

        DynaActionForm dynaForm = (DynaActionForm) form;

        String[] splitString = (String[]) dynaForm.get("idArr");
        LogSupVendorService logSupVendorService = (LogSupVendorService) getBean("logSupVendorService");
        try {
            logSupVendorService.removeAllLogSupVendors(splitString);
            saveActionTripMessage(request,"message.delete" , null);
        } catch (TlmsServiceException e) {
            saveActionErrorMessage(request,GlobalConstants.COMMON_MESSAGE_DELETE_FAIL, null);
            throw e;
        }
        return mapping.findForward("success");
    }
}

⌨️ 快捷键说明

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