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

📄 webform.java

📁 如果遇到MD5加密文件
💻 JAVA
字号:
package com.easyjf.web;

import java.util.Map;

import org.apache.log4j.Logger;

import com.easyjf.util.CommUtil;
/**
*
* <p>Title:Web表单类</p>
* <p>Description: WebForm 负责封装用于用户端显示的数据,并根据页面组件事件触法相应的事件
 * 读取Form中的数据直接使用form.get("属性名")即可 
 * 设置form的属性值使用form.set("属性名",值)即可
 * form负责封装了用于模板文件中显示的变量名。通过IWebAction添加变量值
 * 使用方法:form.addResult("变量名",值)
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: www.easyjf.com</p>
* @author 蔡世友
* @version 1.0
*/
public class WebForm {
private Map textElement;
private Map fileElement;
private Map property;
private FormConfig formConfig;
private Map easyJWebResult;
private static final Logger logger = (Logger) Logger.getLogger(WebForm.class);
public WebForm()
{	
}
public boolean validate()
{
	if(formConfig!=null && (formConfig.getServerValidate().equals("true")||formConfig.getServerValidate().equals("yes")))			
	{
		return doValidate();	
	}
	else
	return true;
}
//把form表单的数据转换成Object对象
public Object toPo(Object obj)
{	
	CommUtil.Map2Obj(this.getTextElement(),obj);
	return obj;
}
//把form表单中的数据转换成classType类对象
public Object toPo(Class classType)
{	
	Object obj=null;
	try{
	obj=classType.newInstance();
	CommUtil.Map2Obj(this.getTextElement(),obj);
	}
	catch(Exception e)
	{
		e.printStackTrace();
	}
	return obj;
}
//PO对象中的数据存放到FORM对象中
public void addPo(Object obj)
{
	if(obj!=null)
	CommUtil.Obj2Map(obj,this.getTextElement());
}
/**
 * 通过配置文件中的检验设置分别校验表单数据
 * @return
 */
protected boolean doValidate()
{	
	return true;
}
public Object get(String name) //throws NoPropertyException
{	
	//System.out.println("返回值吗?"+((this.getClass()!=WebForm.class)&&(!property.containsKey(name))));
	if((this.getClass()!=WebForm.class)&&(!property.containsKey(name)))return null;
	//throw new NoPropertyException("the property '"+name+"' is not exist!");
	//System.out.println("返回值吗?"+fileElement.size());
	if(textElement.containsKey(name))return textElement.get(name);
	else return fileElement.get(name);
	//throw new NoPropertyException("the property '"+name+"' is not exist!");		
}

public void set(String key,Object value)
{
	if(textElement.containsKey(key))textElement.put(key,value);
	else if(fileElement.containsKey(key))fileElement.put(key,value);
	else logger.error("表单中没有该属性!");
}
public Map getFileElement() {
	return fileElement;
}
public void setFileElement(Map fileElement) {
	this.fileElement = fileElement;
}
public Map getTextElement() {
	return textElement;
}
public void setTextElement(Map textElement) {
	this.textElement = textElement;
}
public Map getProperty() {
	return property;
}
public void setProperty(Map property) {
	this.property = property;
}
public FormConfig getFormConfig() {
	return formConfig;
}
public void setFormConfig(FormConfig formConfig) {
	this.formConfig = formConfig;
}

public Map getEasyJWebResult() {
	return easyJWebResult;
}

public void setEasyJWebResult(Map easyJWebResult) {
	this.easyJWebResult = easyJWebResult;
}
/**
 * 设置模板文件中的变量值
 * @param key
 * @param value
 */
public void addResult(String key,Object value)
{
	if(!key.equals("easyJWebResult"))easyJWebResult.put(key,value);
	else logger.error("企图使用EasyJWeb系统关键字easyJWebResult保存数据失败");
}
}

⌨️ 快捷键说明

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