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

📄 informationeditform.java

📁 这个是完整的wap项目的源码 开发语言 Java 系统架构 Struts + hibernate + spring 数据库 Mysql5.0 应用服务器Tomcat5.0 开发工具 MyEc
💻 JAVA
字号:
package com.longtime.wap.module.information.web.form;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.validator.GenericValidator;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import org.apache.struts.validator.ValidatorForm;

/**
 * 编辑信息表单
 * 
 * @author bulc
 * @date   Nov 19, 2007
 */
public class InformationEditForm extends ValidatorForm {
	private static final long serialVersionUID = 1L;
	
	private String detailType;
	private String editFlug;
	private String informationId;
	private String businessId;
	private String businessName;
	private String title;
	private String price;
	private boolean isHot;
	private boolean isRecommend;
	private boolean isPub;
	private boolean isOverdue;
	private String content;
	private String filePath;
	private FormFile uploadFile;
	
	private String searchValue;
	private String searchType;
	
	private String currentPage;
	
	/**
	 * 重写回复函数
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param request
	 *            HttpServletRequest对象
	 */
	@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		informationId = null;
		detailType = null;
		editFlug = null;
		businessName = null;
		title = null;
		price = null;
		isHot = false;
		isRecommend = false;
		isPub = false;
		content = null;
		uploadFile = null;
		filePath = null;
		businessId = null;
		searchValue = null;
		searchType = null;
		currentPage = null;
	}
	
	/**
	 * 验证表单数据
	 * 
	 * @param mapping
	 *            ActionMapping对象
	 * @param request
	 *            HttpServletRequest对象
	 * @return 错误提示信息
	 */
	@Override
	public ActionErrors validate(ActionMapping mapping, 
			HttpServletRequest request) {
		ActionErrors errors = super.validate(mapping, request);
		if (!StringUtils.isBlank(price)){
			if (GenericValidator.isDouble(price)) {
				Double informationPrice = Double.parseDouble(price);
				if (price.startsWith("-")) {
					errors.add("price", 
							new ActionError("errors.pricenegative"));
				} else if (informationPrice > 5.00){
					errors.add("price", 
							new ActionError("errors.priceoutofrange"));
				} else if (price.contains(".") 
						&& price.split("\\.").length == 2 
						&& price.split("\\.")[1].length() > 2){
					errors.add("price", 
							new ActionError("errors.priceinvalidformat"));
				}
			} else {
				errors.add("price", new ActionError("errors.double"));
			}
		} else {
			errors.add("price", new ActionError("errors.required"));
		}
		if (editFlug.equalsIgnoreCase("save")
				&& !detailType.equalsIgnoreCase("text")) {
			if (null != uploadFile 
					&& !StringUtils.isEmpty(uploadFile.getFileName())) {
				String[] fileNameArray = uploadFile.getFileName().split("\\.");
				if (fileNameArray.length == 2) {
					if ((detailType.equalsIgnoreCase("pic")
							&& !isAllowedPicType(
									fileNameArray[1].toLowerCase()))
							|| detailType.equalsIgnoreCase("music")
							&& !isAllowedMusicType(
									fileNameArray[1].toLowerCase())) {
						errors.add("uploadFile", 
								new ActionError("errors.invalidtype"));
					}
				} else {
					errors.add("uploadFile", 
							new ActionError("errors.invalieduploadfilename"));
				}
			} else {
				errors.add("uploadFile", new ActionError("errors.required"));
			}
		}
		return errors;
	}
	
	/**
	 * 检验传入图片的文件扩展名是否为允许上传的类型
	 * 
	 * @param extension 
	 * 				文件扩展名
	 * @return 是否为允许类型
	 */
	private boolean isAllowedPicType(String extension) {
		List<String> allowedPicType = new ArrayList<String>();
		allowedPicType.add("jpg");
		allowedPicType.add("jpeg");
		allowedPicType.add("png");
		allowedPicType.add("bmp");
		allowedPicType.add("gif");

		if (allowedPicType.contains(extension)) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 检验传入音乐的文件扩展名是否为允许上传的类型
	 * 
	 * @param extension
	 * 				文件扩展名
	 * @return 文件名是否符合格式
	 */
	private boolean isAllowedMusicType(String extension) {
		List<String> allowedMusicType = new ArrayList<String>();
		allowedMusicType.add("mp3");
		allowedMusicType.add("m4a");
		allowedMusicType.add("wma");
		allowedMusicType.add("wav");

		if (allowedMusicType.contains(extension)) {
			return true;
		} else {
			return false;
		}
	}

	/**
	 * 获取业务编号
	 * 
	 * @return 业务编号
	 */
	public String getBusinessId() {
		return businessId;
	}

	/**
	 * 设置业务编号
	 * 
	 * @param businessId
	 * 				业务编号
	 */
	public void setBusinessId(String businessId) {
		this.businessId = businessId;
	}

	/**
	 * 获取业务名称
	 * 
	 * @return 业务名称
	 */
	public String getBusinessName() {
		return businessName;
	}

	/**
	 * 设置业务名称
	 * 
	 * @param businessName
	 * 				业务名称
	 */
	public void setBusinessName(String businessName) {
		this.businessName = businessName;
	}

	/**
	 * 获取信息内容
	 * 
	 * @return 信息内容
	 */
	public String getContent() {
		return content;
	}

	/**
	 * 设置信息内容
	 * 
	 * @param content
	 * 			信息内容
	 */
	public void setContent(String content) {
		this.content = content;
	}

	/**
	 * 获取信息详细内容类型
	 * 
	 * @return 信息详细内容类型
	 */
	public String getDetailType() {
		return detailType;
	}

	/**
	 * 设置信息详细内容类型
	 * 
	 * @param detailType
	 * 				信息详细内容类型
	 */
	public void setDetailType(String detailType) {
		this.detailType = detailType;
	}

	/**
	 * 获取操作标记
	 * 
	 * @return 操作标记
	 */
	public String getEditFlug() {
		return editFlug;
	}

	/**
	 * 设置操作标记
	 * 
	 * @param editFlug
	 * 				操作标记
	 */
	public void setEditFlug(String editFlug) {
		this.editFlug = editFlug;
	}

	/**
	 * 获取文件上传路径
	 * 
	 * @return 文件上传路径
	 */
	public String getFilePath() {
		return filePath;
	}

	/**
	 * 设置文件上传路径
	 * 
	 * @param filePath
	 * 				文件上传路径
	 */
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}

	/**
	 * 获取信息编号
	 * 
	 * @return 信息编号
	 */
	public String getInformationId() {
		return informationId;
	}

	/**
	 * 设置信息编号
	 * 
	 * @param informationId
	 * 					信息编号
	 */
	public void setInformationId(String informationId) {
		this.informationId = informationId;
	}

	/**
	 * 判断信息是否热门
	 * 
	 * @return 信息是否热门
	 */
	public boolean getIsHot() {
		return isHot;
	}

	/**
	 * 设置信息是否热门
	 * 
	 * @param isHot
	 * 			是否热门
	 */
	public void setIsHot(boolean isHot) {
		this.isHot = isHot;
	}

	/**
	 * 判断信息是否过期
	 * 
	 * @return 信息是否过期
	 */
	public boolean getIsOverdue() {
		return isOverdue;
	}

	/**
	 * 设置信息是否过期
	 * 
	 * @param isOverdue
	 * 				是否过期
	 */
	public void setIsOverdue(boolean isOverdue) {
		this.isOverdue = isOverdue;
	}

	/**
	 * 判断信息是否已发布
	 * 
	 * @return 信息是否已发布
	 */
	public boolean getIsPub() {
		return isPub;
	}

	/**
	 * 设置信息是否已经发布
	 * 
	 * @param isPub
	 * 			信息是否已经发布
	 */
	public void setIsPub(boolean isPub) {
		this.isPub = isPub;
	}

	/**
	 * 判断信息是否已推荐
	 * 
	 * @return 信息是否已推荐
	 */
	public boolean getIsRecommend() {
		return isRecommend;
	}

	/**
	 * 设置信息是否已推荐
	 * 
	 * @param isRecommend
	 * 				信息是否已推荐
	 */
	public void setIsRecommend(boolean isRecommend) {
		this.isRecommend = isRecommend;
	}

	/**
	 * 获取信息价格
	 * 
	 * @return 信息价格
	 */
	public String getPrice() {
		return price;
	}

	/**
	 * 设置信息价格
	 * 
	 * @param price
	 * 			信息价格
	 */
	public void setPrice(String price) {
		this.price = price;
	}

	/**
	 * 获取信息标题
	 * 
	 * @return 信息标题
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * 设置信息标题
	 * 
	 * @param title
	 * 			信息标题
	 */
	public void setTitle(String title) {
		this.title = title;
	}

	/**
	 * 获取文件上传路径
	 * 
	 * @return 文件上传路径
	 */
	public FormFile getUploadFile() {
		return uploadFile;
	}

	/**
	 * 设置文件上传路径
	 * 
	 * @param uploadFile
	 * 				文件上传路径
	 */
	public void setUploadFile(FormFile uploadFile) {
		this.uploadFile = uploadFile;
	}

	/**
	 * 获取搜索类型
	 * 
	 * @return 搜索类型
	 */
	public String getSearchType() {
		return searchType;
	}

	/**
	 * 设置搜索类型
	 * 
	 * @param searchType
	 * 				搜索类型
	 */
	public void setSearchType(String searchType) {
		this.searchType = searchType;
	}

	/**
	 * 获取搜索内容
	 * 
	 * @return 搜索内容
	 */
	public String getSearchValue() {
		return searchValue;
	}

	/**
	 * 设置搜索内容
	 * 
	 * @param searchValue
	 * 				搜索内容
	 */
	public void setSearchValue(String searchValue) {
		this.searchValue = searchValue;
	}

	/**
	 * 获取信息列表当前页
	 * 
	 * @return 信息列表当前页
	 */
	public String getCurrentPage() {
		return currentPage;
	}

	/**
	 * 设置信息列表当前页
	 * 
	 * @param currentPage
	 * 				信息列表当前页
	 */
	public void setCurrentPage(String currentPage) {
		this.currentPage = currentPage;
	}

}

⌨️ 快捷键说明

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