banq,你做的软件做的怎末样了

02-12-03 nmg
banq,你做的网站引擎软件做的怎末样了,想好怎末卖了吗?

做市场是非常主要的!你打算如何去做市场?

nmg
2002-12-03 15:56
banq?做的怎末样了

nmg
2004-08-09 20:06
时光匆匆

banq
2004-08-10 12:58
多谢,现在主要做JdonSD框架了

banq
2004-08-10 13:31
哪里有无你的系统介绍,非常大,我下载了,在欣赏中,原来多日不见,闭门修炼去了,佩服。

jody
2004-08-10 15:25
我靠。。。本来想学习学习这个代码生成的软件。。

10多MB。。。吓人。。在这个 Ant 和velocity盛行的年代。。。居然能做出那么大的一个软件。。。真是佩服啊。。。

小弟我用 ant + velocity 也做了代码生成工具。。

生成form 用的是公用form strutsconf ,strutsaction .HibernateBMP,Hibernate javacode ,以及struts 的前台表现层velocity ,一次生成,对表生成操作为 浏览,添加.删除.修改,查寻,翻页,打印。,,,,感觉还是不复杂的

sunw
2004-08-10 16:47
banq 现在不做软件了 ,做教育 做框架了 , 是吧

haibo
2004-08-10 16:48
我不太懂你所说的“代码生成工具”是什么。但从你说的生成表操作添加.删除.修改,查寻,翻页,打印等等,如果这样的代码需要"批量生成”

的话,设计肯定没有做好,否则不会出现冗余

banq
2004-08-11 11:36
to jody

你的生成器是否有介绍和演示?想看看。。。

jody
2004-08-13 12:45
生成代码的样子。

IE下浏览

Mozilla下浏览

jody
2004-08-13 12:46
代码:

package com.coolwen.ant;

import javax.sql.DataSource;

import org.apache.commons.dbcp.BasicDataSource;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;


/**
 * TODO 
 *
 * @author <a href="mailto:jody@cpgroup.cn>QiaoLu</a>
 * @Date:2004-7-23
 */
public abstract class AbstractTask  extends Task{
	
	protected String datasourceDriver;
	protected String datasourceUrl;
	protected String datasourceUsername;
	protected String datasourcePassword;
	
	protected Project project;

	/**
	 * @return Returns the datasourceDriver.
	 */
	public String getDatasourceDriver() {
		return datasourceDriver;
	}
	/**
	 * @param datasourceDriver The datasourceDriver to set.
	 */
	public void setDatasourceDriver(String datasourceDriver) {
		this.datasourceDriver = datasourceDriver;
	}
	/**
	 * @return Returns the datasourcePassword.
	 */
	public String getDatasourcePassword() {
		return datasourcePassword;
	}
	/**
	 * @param datasourcePassword The datasourcePassword to set.
	 */
	public void setDatasourcePassword(String datasourcePassword) {
		this.datasourcePassword = datasourcePassword;
	}
	/**
	 * @return Returns the datasourceUrl.
	 */
	public String getDatasourceUrl() {
		return datasourceUrl;
	}
	/**
	 * @param datasourceUrl The datasourceUrl to set.
	 */
	public void setDatasourceUrl(String datasourceUrl) {
		this.datasourceUrl = datasourceUrl;
	}
	/**
	 * @return Returns the datasourceUsername.
	 */
	public String getDatasourceUsername() {
		return datasourceUsername;
	}
	/**
	 * @param datasourceUsername The datasourceUsername to set.
	 */
	public void setDatasourceUsername(String datasourceUsername) {
		this.datasourceUsername = datasourceUsername;
	}
	protected DataSource getDataSource(){
		BasicDataSource ds = new BasicDataSource();
		ds.setDriverClassName(this.getDatasourceDriver());
		ds.setUsername(this.getDatasourceUsername());
		ds.setPassword(this.getDatasourcePassword());
		ds.setUrl(this.getDatasourceUrl());
		return ds;
	}
	public abstract void execute () throws BuildException;
	
	
	/**
	 * @return Returns the project.
	 */
	public Project getProject() {
		return project;
	}
	/**
	 * @param project The project to set.
	 */
	public void setProject(Project project) {
		this.project = project;
	}
}
<p>

jody
2004-08-13 12:47
代码 生成 HBM 和JAVA

package com.coolwen.ant.hibernate;

import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

import net.sf.hibernate.tool.ddl2hbm.MapGenerator;

import org.apache.tools.ant.BuildException;

import com.coolwen.ant.AbstractTask;

/**
 * TODO 
 *
 * @author <a href="mailto:jody@cpgroup.cn>QiaoLu</a>
 * @Date:2004-7-23
 */
public class HibernateTask extends AbstractTask {
	
	protected String coolwen_hibernate_package;
	
	protected String coolwen_hibernate_schem;
	
	protected String[] coolwen_hibernate_tables;
	
	protected String coolwen_hibernate_catalog;
	
	protected String coolwen_hibernate_idname;
	
	protected String coolwen_hibernate_idtype; 
	
	protected File coolwen_hibernate_outDir;
	
	protected String coolwen_hibernate_generator;
	
	protected boolean coolwen_hibernate_Java;
	
	protected boolean coolwen_hibernate_Hbm;
	
	protected boolean coolwen_hibernate_singlemap;
	
	protected String coolwen_hibernate_singlemapname;
	
	
	
	
	/* (non-Javadoc)
	 * @see com.coolwen.ant.AbstractTaskexecute()
	 */
	public void execute() throws BuildException {
		// TODO Auto-generated method stub
		MapGenerator mg = new MapGenerator();
		mg.setCatalog(this.getCoolwen_hibernate_catalog());
		mg.setSchemaPattern(this.getCoolwen_hibernate_schem());
		mg.setIdName(this.getCoolwen_hibernate_idname());
		mg.setIdType(this.getCoolwen_hibernate_idtype());
		mg.setTableNames(this.getCoolwen_hibernate_tables());
		mg.setPackageName(this.getCoolwen_hibernate_package());
		mg.setHibernateTypes(true);
		mg.setGenerator(this.getCoolwen_hibernate_generator());
		mg.setOutputDirectory(this.getCoolwen_hibernate_outDir());
		mg.setSingleMapFile(this.isCoolwen_hibernate_singlemap());
		mg.setMappingFile(this.getCoolwen_hibernate_singlemapname());
		mg.setJava(this.isCoolwen_hibernate_Java());
		mg.setHbm(this.isCoolwen_hibernate_Hbm());
		try {
			mg.generate(this.getDataSource().getConnection());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * @return Returns the coolwen_hibernate_package.
	 */
	public String getCoolwen_hibernate_package() {
		return coolwen_hibernate_package;
	}
	/**
	 * @param coolwen_hibernate_package The coolwen_hibernate_package to set.
	 */
	public void setCoolwen_hibernate_package(String coolwen_hibernate_package) {
		this.coolwen_hibernate_package = coolwen_hibernate_package;
	}
	
	
	/**
	 * @return Returns the coolwen_hibernate_schem.
	 */
	public String getCoolwen_hibernate_schem() {
		return coolwen_hibernate_schem;
	}
	/**
	 * @param coolwen_hibernate_schem The coolwen_hibernate_schem to set.
	 */
	public void setCoolwen_hibernate_schem(String coolwen_hibernate_schem) {
		this.coolwen_hibernate_schem = coolwen_hibernate_schem;
	}
	
	/**
	 * @return Returns the coolwen_hibernate_tables.
	 */
	public String[] getCoolwen_hibernate_tables() {
		return coolwen_hibernate_tables;
	}
	/**
	 * @param coolwen_hibernate_tables The coolwen_hibernate_tables to set.
	 */
	public void setCoolwen_hibernate_tables(String coolwen_hibernate_tables) {
		String[] result = null;
		if(coolwen_hibernate_tables.toUpperCase().equals("*")){
			Connection conn = null;
			
			try {
				conn = this.getDataSource().getConnection();
				DatabaseMetaData dmd =conn.getMetaData();
				ResultSet rs = null;
				rs = dmd.getTables(this.getCoolwen_hibernate_catalog(), this.coolwen_hibernate_schem, "%", new String[] {"TABLE", "VIEW", "SYNONYM", "ALIAS"} );
				List l = new LinkedList();
				while (rs.next()) {
					l.add(rs.getString(3));
				}
				result = new String[l.size()];
				for(int i = 0 ; i< l.size(); i++){
					result[i] = (String)l.get(i);
				}
				rs.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally {
				if(conn != null)
					try {
						conn.close();
					} catch (SQLException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
			}
		}else{
			StringTokenizer fqcnTokenizer = new StringTokenizer(coolwen_hibernate_tables, ";", false);
			
			result = new String[fqcnTokenizer.countTokens()];
			while (fqcnTokenizer.hasMoreTokens()) {
				result[fqcnTokenizer.countTokens()-1] = fqcnTokenizer.nextToken().trim().toUpperCase();
			}
		}
		this.coolwen_hibernate_tables = result;
	}
	
	/**
	 * @return Returns the coolwen_hibernate_catalog.
	 */
	public String getCoolwen_hibernate_catalog() {
		return coolwen_hibernate_catalog;
	}
	/**
	 * @param coolwen_hibernate_catalog The coolwen_hibernate_catalog to set.
	 */
	public void setCoolwen_hibernate_catalog(String coolwen_hibernate_catalog) {
		this.coolwen_hibernate_catalog = coolwen_hibernate_catalog;
	}
	/**
	 * @return Returns the coolwen_hibernate_idname.
	 */
	public String getCoolwen_hibernate_idname() {
		return coolwen_hibernate_idname;
	}
	/**
	 * @param coolwen_hibernate_idname The coolwen_hibernate_idname to set.
	 */
	public void setCoolwen_hibernate_idname(String coolwen_hibernate_idname) {
		this.coolwen_hibernate_idname = coolwen_hibernate_idname;
	}
	/**
	 * @return Returns the coolwen_hibernate_idtype.
	 */
	public String getCoolwen_hibernate_idtype() {
		return coolwen_hibernate_idtype;
	}
	/**
	 * @param coolwen_hibernate_idtype The coolwen_hibernate_idtype to set.
	 */
	public void setCoolwen_hibernate_idtype(String coolwen_hibernate_idtype) {
		this.coolwen_hibernate_idtype = coolwen_hibernate_idtype;
	}
	
	/**
	 * @return Returns the coolwen_hibernate_outDir.
	 */
	public File getCoolwen_hibernate_outDir() {
		return coolwen_hibernate_outDir;
	}
	/**
	 * @param coolwen_hibernate_outDir The coolwen_hibernate_outDir to set.
	 */
	public void setCoolwen_hibernate_outDir(File coolwen_hibernate_outDir) {
		this.coolwen_hibernate_outDir = coolwen_hibernate_outDir;
	}
	
	/**
	 * @return Returns the coolwen_hibernate_generator.
	 */
	public String getCoolwen_hibernate_generator() {
		return coolwen_hibernate_generator;
	}
	/**
	 * @param coolwen_hibernate_generator The coolwen_hibernate_generator to set.
	 */
	public void setCoolwen_hibernate_generator(
			String coolwen_hibernate_generator) {
		this.coolwen_hibernate_generator = coolwen_hibernate_generator;
	}
	
	/**
	 * @return Returns the coolwen_hibernate_singlemap.
	 */
	public boolean isCoolwen_hibernate_singlemap() {
		return coolwen_hibernate_singlemap;
	}
	/**
	 * @param coolwen_hibernate_singlemap The coolwen_hibernate_singlemap to set.
	 */
	public void setCoolwen_hibernate_singlemap(
			boolean coolwen_hibernate_singlemap) {
		this.coolwen_hibernate_singlemap = coolwen_hibernate_singlemap;
	}
	
	
	/**
	 * @return Returns the coolwen_hibernate_singlemapname.
	 */
	public String getCoolwen_hibernate_singlemapname() {
		return coolwen_hibernate_singlemapname;
	}
	/**
	 * @param coolwen_hibernate_singlemapname The coolwen_hibernate_singlemapname to set.
	 */
	public void setCoolwen_hibernate_singlemapname(
			String coolwen_hibernate_singlemapname) {
		this.coolwen_hibernate_singlemapname = coolwen_hibernate_singlemapname;
	}
	
	/**
	 * @return Returns the coolwen_hibernate_Hbm.
	 */
	public boolean isCoolwen_hibernate_Hbm() {
		return coolwen_hibernate_Hbm;
	}
	/**
	 * @param coolwen_hibernate_Hbm The coolwen_hibernate_Hbm to set.
	 */
	public void setCoolwen_hibernate_Hbm(boolean coolwen_hibernate_Hbm) {
		this.coolwen_hibernate_Hbm = coolwen_hibernate_Hbm;
	}
	/**
	 * @return Returns the coolwen_hibernate_Java.
	 */
	public boolean isCoolwen_hibernate_Java() {
		return coolwen_hibernate_Java;
	}
	/**
	 * @param coolwen_hibernate_Java The coolwen_hibernate_Java to set.
	 */
	public void setCoolwen_hibernate_Java(boolean coolwen_hibernate_Java) {
		this.coolwen_hibernate_Java = coolwen_hibernate_Java;
	}
}

jody
2004-08-13 12:48
生成根据模板生成action ....文件

package com.coolwen.ant.struts;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

import net.sf.hibernate.tool.ddl2hbm.JDBCUtil;
import net.sf.hibernate.util.StringHelper;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;
import org.apache.tools.ant.BuildException;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.context.Context;
import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.texen.Generator;

import com.coolwen.ant.hibernate.HibernateTask;

/**
 * TODO 
 *
 * @author <a href="mailto:jody@cpgroup.cn>QiaoLu</a>
 * @Date:2004-7-29
 */
public class ActionTask extends HibernateTask {
	
	protected static Map template = new HashMap();
	
	protected File coolwen_struts_outpath;
	
	protected String coolwen_struts_schem;
	
	protected String coolwen_struts_templatepath;
	
	protected File coolwen_struts_documentpath;
	
	protected String coolwen_struts_package;
	public List getColumns(List value){
		List result = new ArrayList();
		 for (Iterator iter = value.iterator(); iter.hasNext(); ){
		 	JDBCUtil.Column column = (JDBCUtil.Column)iter.next();
		 	Column newColumn = new Column();
		 	newColumn.setHibernateType(column.hibernateType);
		 	newColumn.setJavaType(column.javaType);
		 	newColumn.setName(column.name.toLowerCase());
		 	newColumn.setSqlColumnLength(column.sqlColumnLength);
		 	newColumn.setSqlDecimalLength(column.sqlDecimalLength);
		 	newColumn.setSqlNotNull(column.sqlNotNull);
		 	newColumn.setSqlReadOnly(column.sqlReadOnly);
		 	newColumn.setSqlType(column.sqlType);
		 	result.add(newColumn);
		 }
		return result;
	}
	/* (non-Javadoc)
	 * @see org.apache.tools.ant.Taskexecute()
	 */
	public void execute () throws BuildException {
		List content = new ArrayList();
		for(int i = 0 ; i < this.getCoolwen_hibernate_tables().length ; i++){
			try {
				List pkColumns = JDBCUtil.getPrimaryKeyColumns(this.getDataSource().getConnection(), this.getCoolwen_hibernate_catalog(), this.getCoolwen_hibernate_schem(), this.getCoolwen_hibernate_tables()[i]);
				Set fkColumns = JDBCUtil.getForeignKeyColumns(this.getDataSource().getConnection(), this.getCoolwen_hibernate_catalog(), this.getCoolwen_hibernate_schem(), this.getCoolwen_hibernate_tables()[i]);				
				List columns = JDBCUtil.getTableColumns(this.getDataSource().getConnection(), this.getCoolwen_hibernate_catalog(), this.getCoolwen_hibernate_schem(), this.getCoolwen_hibernate_tables()[i]);
				
				ActionTemplateData actiontemplat = new ActionTemplateData ();
				actiontemplat.setClassname(this.getCoolwen_hibernate_tables()[i]);
				actiontemplat.setPackagename(this.getCoolwen_hibernate_package());
				actiontemplat.setColumns(this.getColumns(columns));
				actiontemplat.setFkColumns(fkColumns);
				actiontemplat.setPkColumns(this.getColumns(pkColumns));
				content.add(actiontemplat);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		try {
			 VelocityEngine ve = new VelocityEngine();
			 ve.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, this.getCoolwen_struts_templatepath());
			 ve.init();
			 Generator generator = Generator.getInstance();
			 generator.setVelocityEngine(ve);
			 generator.setOutputPath(this.getCoolwen_struts_templatepath());
			 Template template = null;
			 Writer writer = null;
			 //	TODO start struts config generat
			 Context struts = new VelocityContext();
			 struts.put("contents",content);
			 struts.put("schem",this.getCoolwen_struts_schem());
			 struts.put("package",this.getCoolwen_struts_package());
			 //template = generator.getTemplate("strutsTemplate.vm","GBK");
			 template = this.getTemplate(generator,"strutsTemplate.vm");
			 File strutsFile =  this.getCoolwen_struts_documentpath();
			 	  strutsFile = new File(strutsFile,"WEB-INF");
			 	  strutsFile = new File(strutsFile,"struts-config-"+this.getCoolwen_struts_schem()+".xml");
			 	 writer = this.getWriter(strutsFile,null);
			 	template.merge(struts,writer);
				writer.flush();
				writer.close();
				String rootid = this.create("Tree",true,"-1","");
				String schemid = this.create(this.getCoolwen_struts_schem().toLowerCase(),true,rootid,"");
			 for (Iterator iter = content.iterator(); iter.hasNext(); ){
				 Context c = new VelocityContext();
				 c.put("now", new Date().toString());
				 ActionTemplateData tempdata = (ActionTemplateData)iter.next();
				 System.out.println(schemid);
				 this.create(tempdata.classname.toLowerCase(),false,schemid,this.getCoolwen_struts_schem().toLowerCase()+"/"+tempdata.classname.toLowerCase());
				 c.put("content",tempdata);
				 c.put("schem",this.getCoolwen_struts_schem());
				 c.put("package",this.getCoolwen_struts_package()+"."+this.getCoolwen_struts_schem());
				//# TODO struts Action generat
				 File tempf = this.getCoolwen_struts_outpath();
				 tempf = new File(tempf,this.getCoolwen_struts_schem());
				 if(!tempf.exists())
				 	tempf.mkdirs();
				 tempf = new File(tempf,tempdata.classname+"Actions.java");
				 writer = this.getWriter(tempf,null);
				 template = this.getTemplate(generator,"actionTemplate.vm");
				 template.merge(c,writer);
				 writer.flush();
				 writer.close();
				 //c = null;
			    //# TODO struts confit generat
				
				//# Velocity generat
				Map templateMap = new HashMap();
				templateMap.put("add","addTemplate.vm");
				templateMap.put("detail","detailTemplate.vm");
				templateMap.put("list","listTemplate.vm");
				templateMap.put("print","printTemplate.vm");
				templateMap.put("update","updateTemplate.vm");
				templateMap.put("index","indexTemplate.vm");
				templateMap.put("frameMaster","frameMasterTemplate.vm");
				File velocity = this.getCoolwen_struts_documentpath();
					velocity = new File(velocity,this.getCoolwen_struts_schem().toLowerCase()+File.separator+tempdata.getClassname().toLowerCase());
					if(!velocity.exists())
						velocity.mkdirs();
				for(Iterator tmap = templateMap.keySet().iterator(); tmap.hasNext();){
					template = null;
					String key = (String)tmap.next();
					String value = (String)templateMap.get(key);
					writer = null;
		            File veloctiytemp = new File(velocity,key+".vm");
		            writer = this.getWriter(veloctiytemp,null);
		            template = this.getTemplate(generator,value);//generator.getTemplate(value,"GBK");
		            template.merge(c,writer);
					writer.flush();
					writer.close();
		        }
			 }
				
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	protected String makeEntityName(String name) {
		String tmp = makeMemberName(name);
		tmp = tmp.substring(0,1).toUpperCase() + tmp.substring(1);
		return tmp;
	}
	
	protected String makeMemberName(String name) {
		String memberName = name.toLowerCase();
		int i;
		while ( (i = memberName.indexOf(StringHelper.UNDERSCORE) ) != -1 ) {
			java.lang.String tmp1 = memberName.substring(0, i);
			if (i+1 < memberName.length()) {
				tmp1 += memberName.substring(i+1, i+2).toUpperCase();
			}
			if (i+2 < memberName.length()) {
				tmp1 += memberName.substring(i+2);
			}
			memberName = tmp1;
		}
		return memberName;
	}
	
	
	/**
	 * @return Returns the coolwen_struts_outpath.
	 */
	public File getCoolwen_struts_outpath() {
		return coolwen_struts_outpath;
	}
	/**
	 * @param coolwen_struts_outpath The coolwen_struts_outpath to set.
	 */
	public void setCoolwen_struts_outpath(File coolwen_struts_outpath) {
		this.coolwen_struts_outpath = coolwen_struts_outpath;
	}
	/**
	 * @return Returns the coolwen_struts_schem.
	 */
	public String getCoolwen_struts_schem() {
		return coolwen_struts_schem;
	}
	/**
	 * @param coolwen_struts_schem The coolwen_struts_schem to set.
	 */
	public void setCoolwen_struts_schem(String coolwen_struts_schem) {
		this.coolwen_struts_schem = coolwen_struts_schem;
	}
	/**
	 * @return Returns the coolwen_struts_templatepath.
	 */
	public String getCoolwen_struts_templatepath() {		
		return coolwen_struts_templatepath;
	}
	/**
	 * @param coolwen_struts_templatepath The coolwen_struts_templatepath to set.
	 */
	public void setCoolwen_struts_templatepath(
			String coolwen_struts_templatepath) {
		this.coolwen_struts_templatepath = coolwen_struts_templatepath;
	}
	
	/**
	 * @return Returns the coolwen_struts_documentpath.
	 */
	public File getCoolwen_struts_documentpath() {
		return coolwen_struts_documentpath;
	}
	/**
	 * @param coolwen_struts_documentpath The coolwen_struts_documentpath to set.
	 */
	public void setCoolwen_struts_documentpath(
			File coolwen_struts_documentpath) {
		this.coolwen_struts_documentpath = coolwen_struts_documentpath;
	}
	
	/**
	 * @return Returns the coolwen_struts_package.
	 */
	public String getCoolwen_struts_package() {
		return coolwen_struts_package;
	}
	/**
	 * @param coolwen_struts_package The coolwen_struts_package to set.
	 */
	public void setCoolwen_struts_package(String coolwen_struts_package) {
		this.coolwen_struts_package = coolwen_struts_package;
	}
	
    /**
     * Returns a writer, based on encoding and path.
     *
     * @param path      path to the output file
     * @param encoding  output encoding
     */
    public Writer getWriter(File path, String encoding) throws Exception {
        Writer writer;
        if (encoding == null || encoding.length() == 0 || encoding.equals("8859-1") || encoding.equals("8859_1")) {
            writer = new FileWriter(path);
        }
        else {
            writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path), encoding));
        }
        return writer;
    }
    
    public Template getTemplate(Generator generator,String template) throws Exception{
    	Template temp = null;
    	synchronized(ActionTask.template){
    		temp = (Template)ActionTask.template.get(template);
    		if(temp == null){
    			temp = generator.getTemplate(template,"GB2312");
    			ActionTask.template.put(template,temp);
    	 	}
    	}
    	return temp;
    }
    protected String create(String name,boolean isfloder,String parentid,String link){
    	QueryRunner queryRunner = new QueryRunner(this.getDataSource());
    	String id = "";
    	IsExist isExist = new IsExist();
    	String sql = "";
    	if(this.getCoolwen_hibernate_schem()!=null && this.getCoolwen_hibernate_schem().length()>0){
    		sql = "select * from "+this.getCoolwen_hibernate_schem()+".GEN_MENU where NODENAME = '"+name+"' and ISNODE ='"+isfloder+"'" ;
    	}else{
    		sql = "select * from GEN_MENU where NODENAME = '"+name+"' and ISNODE ='"+isfloder+"'" ;
    	}
    	String isexist;
    	try {
    		isexist = queryRunner.query(sql, isExist).toString();
 
		} catch (SQLException e) {
			e.printStackTrace();
			return "0";
		}
		if(isexist.equals("0")){
			if(this.getCoolwen_hibernate_schem()!=null && this.getCoolwen_hibernate_schem().length()>0){
	    		sql = "insert into "+this.getCoolwen_hibernate_schem()+".GEN_MENU(NODEID,NODENAME,ISNODE,PARENTID,LINK,STATE)values(?,?,?,?,?,?)" ;
	    	}else{
	    		sql = "insert into GEN_MENU(NODEID,NODENAME,ISNODE,PARENTID,LINK,STATE)values(?,?,?,?,?,?)" ;
	    	}
			Vector parm = new Vector();
			id = new Date().getTime()+""+(int)(Math.random()*99999);
			parm.add(id);
			parm.add(name);
			parm.add(new Boolean(isfloder));
			parm.add(parentid);
			parm.add(link);
			parm.add(new Boolean(true));
			try {
		            queryRunner.update( sql, parm.toArray());
		    }catch(SQLException e){
		            e.printStackTrace();
		   }
		}else
			id = isexist;
		return id;
    }
	public class IsExist implements ResultSetHandler {
		public Object handle(ResultSet rs) throws SQLException {
			if(rs.next())
				return rs.getObject("NODEID");
			else
				return "0";
		}
	}
}

jody
2004-08-13 12:53
to banq

这只是个demo

最初只是方便我使用。牵扯的地方很多。。我没有整理过。。。

其中用到的是 struts(Velocity DynamicForm action)-spring-hibernate

如果大家觉得这东西有用。。。等我整理过后。。。可以共享给大家使用

banq
2004-08-13 19:28
不错,支持的部件比较多。我在仔细研究中....

建议压缩成rar,用File上传即可。

猜你喜欢
2Go 1 2 下一页