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

📄 videotypeaction.java

📁 本程序是作者开发的一个宽带娱乐系统的一个模块.
💻 JAVA
字号:
package com.singnet.video.struts.action;

import java.rmi.RemoteException;
import java.util.ArrayList;

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

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.singnet.util.Pager;
import com.singnet.util.UserCheck;
import com.singnet.video.VideoTypeInfo;
import com.singnet.video.client.VideoTypeClient;
import com.singnet.video.struts.form.VideoTypeActionForm;

public class VideoTypeAction extends DispatchAction {
	private VideoTypeClient client = new VideoTypeClient();

	public ActionForward add(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws CreateException, RemoteException, Exception {
		VideoTypeInfo videoTypeinfo = new VideoTypeInfo();
		VideoTypeActionForm videoTypeActionForm = (VideoTypeActionForm) form;
		if (videoTypeActionForm.getTypename() == null) {
			return mapping.findForward("add");
		}
		if (videoTypeActionForm.getTypename().equals("")) {
			request.setAttribute("message",
					JspMessageConst.MODULE_VIDEOTYPE_ADD_NONAME);
			return mapping.findForward("add");
		}
		if(client.getVideoTypeByTypename(videoTypeActionForm.getTypename())!=null)
		{
			request.setAttribute("message",
					JspMessageConst.MODULE_VIDEOTYPE_ADD_EXSIT);
			return mapping.findForward("add");
		}
		videoTypeinfo.setRemark(videoTypeActionForm.getRemark());
		videoTypeinfo.setTypename(videoTypeActionForm.getTypename());
		
		if (client.addVideoTypeInfo(videoTypeinfo)) {
			request.setAttribute("message",
					JspMessageConst.MODULE_VIDEOTYPE_ADD_SUCCESS);
		} else {
			request.setAttribute("message",
					JspMessageConst.MODULE_VIDEOTYPE_ADD_FAILURE);
		}
		return mapping.findForward("add");
	}

	public ActionForward edit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws CreateException, RemoteException, Exception {
		VideoTypeInfo videoTypeinfo = new VideoTypeInfo();
		VideoTypeActionForm videoTypeActionForm = (VideoTypeActionForm) form;
		String id = request.getParameter("id");
		
		//判断ID是否合法
		if (id == null || id.equals("") || id.length() < 1||!com.singnet.util.Format.isNumber(id)) {
			request.setAttribute("message",
					JspMessageConst.SYSTEM_ERROR_WrongVars);
			return mapping.findForward("error");
		}
		videoTypeinfo = client.getVideoTypeById(id);
		//get进入的情况
		if (videoTypeActionForm.getTypename() == null) {
			request.setAttribute("videotypeinfo", videoTypeinfo);
			
			return mapping.findForward("edit");
		}
		//post进入,判断是否有输入类型名称
		if (videoTypeActionForm.getTypename().equals("")) {
			request.setAttribute("message",
					JspMessageConst.MODULE_VIDEOTYPE_ADD_NONAME);
			request.setAttribute("videotypeinfo", videoTypeinfo);
			return mapping.findForward("edit");
		}

		videoTypeinfo.setRemark(videoTypeActionForm.getRemark());
		videoTypeinfo.setTypename(videoTypeActionForm.getTypename());

		if (client.editVideoTypeInfo(videoTypeinfo)) {
			request.setAttribute("message",
					JspMessageConst.MODULE_VIDEOTYPE_EDIT_SUCCESS);
		} else {
			request.setAttribute("message",
					JspMessageConst.MODULE_VIDEOTYPE_EDIT_FAILURE);
		}
		request.setAttribute("videotypeinfo", videoTypeinfo);
		return mapping.findForward("edit");
	}

	public ActionForward list(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws CreateException, RemoteException, Exception {
		VideoTypeInfo videoTypeinfo = new VideoTypeInfo();
		VideoTypeActionForm videoTypeActionForm = (VideoTypeActionForm) form;
		UserCheck uc=new UserCheck(request);
		/**
		 * 删除操作开始
		 */
		String action = request.getParameter("action");
		if (action != null && action.equals("delete")) {
			String[] id = request.getParameterValues("sel_id");
			for (int i = 0; i < id.length; i++) {
				//删除开始
				if (client.deleteVideoTypeInfo(id[i])) {
					request.setAttribute("message",JspMessageConst.MODULE_VIDEOTYPE_DELETE_SUCCESS);
				}else{
					request.setAttribute("message",JspMessageConst.MODULE_VIDEOTYPE_DELETE_SUCCESS);
				}
			}
		}
		Pager pager=new Pager();
		ArrayList list=new ArrayList();
		String sql_str="select * from videotype";
		pager.setQueryCase(sql_str);
		list=		client.queryVideoTypeInfo(pager);
		request.setAttribute("list",list);
		return mapping.findForward("list");
	}
}

⌨️ 快捷键说明

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