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

📄 gdaction.java

📁 本书由浅入深、循序渐进地介绍了MVC的体系结构和如何构建一个基于MVC的Web框架
💻 JAVA
字号:
package com.gd.mvc.action.impl;

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

import com.gd.mvc.action.Action;
import com.gd.mvc.exception.VODataValidate;
import com.gd.mvc.io.InfoInAndOut;

public abstract class GdAction implements Action{
	
	public InfoInAndOut infoIn = null;
	public InfoInAndOut infoOut = null;
	
	public InfoInAndOut doAction(InfoInAndOut infoIn) {
		String action = (infoIn.get("action") == null) ? "" : (String)infoIn.get("action");
		InfoInAndOut infoOut = infoIn;
		return infoOut;
	}
	
	/**该方法设置初始信息
	* @param infoIn
	* @return void
	*/

	public void doInit(InfoInAndOut infoIn, InfoInAndOut infoOut) throws Exception {
		this.infoIn = infoIn;
		this.infoOut = infoOut;
		String action = (infoIn.get("action") == null) ? "" : (String)infoIn.get("action");
		List voId = (infoIn.get("voId") == null) ? new ArrayList() : (List)infoIn.get("voId");//获取Xml中设定的voId
	    List voClass = (infoIn.get("voClass") == null) ? new ArrayList() : (List)infoIn.get("voClass");//获取Xml中设定的voClass
	    List voType = (infoIn.get("voType") == null) ? new ArrayList() : (List)infoIn.get("voType");//获取Xml中设定的voType
	    List voValidate = (infoIn.get("voValidate") == null) ? new ArrayList() : (List)infoIn.get("voValidate");//获取Xml中设定的voValidate
		
	    try {
	    	//假如从页面传来的动作不为空,则验证VO
	    	for (int i = 0; !"".equals(action) && voId.size() > i; i++) {
	    		//假如Xml中设定了验证VO
		    	if (voValidate.get(i) != null && "Y".equals(((String)voValidate.get(i)).toUpperCase())) {
		    		//假如是单笔
		    		if ("single".equals((String)voType.get(i))) {
		    			infoIn.put((String)voId.get(i), infoIn.getVO((String)voId.get(i)));
		    		//假如是多笔
		    		} else if ("many".equals((String)voType.get(i))) {
		    			infoIn.put((String)voId.get(i), infoIn.getVOs((String)voId.get(i)));
		    		}
		    	}
		    }
		} catch(VODataValidate e) {
			throw new VODataValidate(e.getMessage());
		}  catch(Exception e) {
			e.printStackTrace();
		}
  	}
	/**
	 * 用于在执行具体动作前,进行初始化
	 */
	public void doBegin()  throws Exception{
		
	}
	/**
	 * 用于在执行完动作后,进行收尾工作
	 */
	public void doEnd()  throws Exception{
		
	}
	
}

⌨️ 快捷键说明

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