courseform.java

来自「java 框架核心技术编程」· Java 代码 · 共 215 行

JAVA
215
字号
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package org.lxh.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 * MyEclipse Struts Creation date: 06-14-2007
 * 
 * XDoclet definition:
 * 
 * @struts.form name="courseForm"
 */
public class CourseForm extends ActionForm {
	/*
	 * Generated fields
	 */
	private int type;

	/** creditHour property */
	private String creditHour;

	/** teacher property */
	private String teacher;

	/** name property */
	private String name;

	/** cid property */
	private String cid;

	/*
	 * Generated Methods
	 */

	/**
	 * Method validate
	 * 
	 * @param mapping
	 * @param request
	 * @return ActionErrors
	 */
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();
		switch (type) {
		case 0: {
			// type=0:查询全部、模糊查询
			break;
		}
		case 1: {
			// type=1:按ID查询、按ID删除 (空或不是数字)
			if (this.cid == null || "".equals(this.cid)) {
				errors.add("cid", new ActionMessage("null.course.cid"));
			} else {
				if (!this.cid.matches("\\d*")) {
					errors.add("cid", new ActionMessage("err.course.cid"));
				}
			}
			break;
		}
		case 2: {
			// type=2:插入新数据:姓名、年龄(空或不是数字)、性别
			if (this.name == null || "".equals(this.name)) {
				errors.add("name", new ActionMessage("null.course.name"));
			}
			if (this.creditHour == null || "".equals(this.creditHour)) {
				errors.add("creditHour", new ActionMessage(
						"null.course.creditHour"));
			} else {
				if (!this.creditHour.matches("\\d*")) {
					errors.add("creditHour", new ActionMessage(
							"err.course.creditHour"));
				}
			}
			if (this.teacher == null || "".equals(this.teacher)) {
				errors.add("teacher", new ActionMessage("null.course.teacher"));
			}
			break;
		}
		case 3: {
			// type=3:更新数据:ID、姓名、年龄(空或不是数字)、性别
			if (this.cid == null || "".equals(this.cid)) {
				errors.add("cid", new ActionMessage("null.course.cid"));
			} else {
				if (!this.cid.matches("\\d*")) {
					errors.add("cid", new ActionMessage("err.course.cid"));
				}
			}
			if (this.name == null || "".equals(this.name)) {
				errors.add("name", new ActionMessage("null.course.name"));
			}
			if (this.creditHour == null || "".equals(this.creditHour)) {
				errors.add("creditHour", new ActionMessage(
						"null.course.creditHour"));
			} else {
				if (!this.creditHour.matches("\\d*")) {
					errors.add("creditHour", new ActionMessage(
							"err.course.creditHour"));
				}
			}
			if (this.teacher == null || "".equals(this.teacher)) {
				errors.add("teacher", new ActionMessage("null.course.teacher"));
			}
			break;
		}
		default: {
			// 表示未知操作
			errors.add("unknow", new ActionMessage("err.unknow"));
			break;
		}
		}
		return errors;
	}

	/**
	 * Method reset
	 * 
	 * @param mapping
	 * @param request
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		// TODO Auto-generated method stub
	}

	/**
	 * Returns the creditHour.
	 * 
	 * @return String
	 */
	public String getCreditHour() {
		return creditHour;
	}

	/**
	 * Set the creditHour.
	 * 
	 * @param creditHour
	 *            The creditHour to set
	 */
	public void setCreditHour(String creditHour) {
		this.creditHour = creditHour;
	}

	/**
	 * Returns the teacher.
	 * 
	 * @return String
	 */
	public String getTeacher() {
		return teacher;
	}

	/**
	 * Set the teacher.
	 * 
	 * @param teacher
	 *            The teacher to set
	 */
	public void setTeacher(String teacher) {
		this.teacher = teacher;
	}

	/**
	 * Returns the name.
	 * 
	 * @return String
	 */
	public String getName() {
		return name;
	}

	/**
	 * Set the name.
	 * 
	 * @param name
	 *            The name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Returns the cid.
	 * 
	 * @return String
	 */
	public String getCid() {
		return cid;
	}

	/**
	 * Set the cid.
	 * 
	 * @param cid
	 *            The cid to set
	 */
	public void setCid(String cid) {
		this.cid = cid;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
}

⌨️ 快捷键说明

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