richfaces的实现的list展现

       在做richafces的过程中,遇到了好多的问题,因为自己没有从头学起,所以好多的东西都是在实践中去明白,感觉走了点弯路,但也明白了好多的机制。

      1、在jsf中页面是预先编译的,因为弹出的pananel也是预加载的,所以在pannel弹出的时候记得要刷新,只有刷新,弹出的数据才能更新。

      2、bean中的get方法在预编译的时候是要调用的。

      3、父类子类转换是自动的。

      在做数据源的过程中,因为不同的数据源字段是不一样,所以在实现过程中有一个父类是公共字段,而子类在继承的父类的基础上加上自己特有的字段,所以添加和修改在做的过程中会比较复杂,而展现是在父类公共字段的展现,比较简单。

      先看一下做出的结果:



 

2、看一下具体的实现

1、在底层中我们封装了数据源的接口和实现,采用了单利和外观的方式,代码如下所示:

package com.cvicse.report.ui.portal.api;

import java.util.List;

import com.cvicse.inforreport.model.datasource.Datasource;

public interface IDataSource {

	/**
	 * 获取所有数据源列表操作
	 * 
	 * @return
	 * @throws Exception
	 */
	public abstract List<Datasource> getAllDSList() throws Exception;

	/**
	 * 获取不同数据源列表操作
	 * 
	 * @param type
	 *            :db、txt、server、soap
	 * @return
	 * @throws Exception
	 */
	public abstract List<Datasource> getDSList(String type) throws Exception;

	/**
	 * 添加数据源操作
	 * 
	 * @param Datasource
	 *            :DBDatasource、TXTDatasource、ServerDatasource、WSDatasource
	 * @throws Exception
	 */
	public abstract void addDataSource(Datasource dataSource) throws Exception;

	/**
	 * 删除数据源操作
	 * 
	 * @param Datasource
	 *            :DBDatasource、TXTDatasource、ServerDatasource、WSDatasource
	 * @throws Exception
	 */
	public abstract void deleteDataSource(Datasource dataSource)
			throws Exception;

	/**
	 * 修改数据源操作
	 * 
	 * @param Datasource
	 *            :DBDatasource、TXTDatasource、ServerDatasource、WSDatasource
	 * @throws Exception
	 */
	public abstract void editDataSource(Datasource dataSource) throws Exception;

	/**
	 * 测试数据源操作
	 * 
	 * @param Datasource
	 *            :DBDatasource、TXTDatasource、ServerDatasource、WSDatasource
	 * @return
	 * @throws Exception
	 */
	public abstract String testDataSource(Datasource dataSource)
			throws Exception;

	/**
	 * 判断数据源是否存在
	 * 
	 * @param Datasource
	 *            :DBDatasource、TXTDatasource、ServerDatasource、WSDatasource
	 * @return
	 * @throws Exception
	 */
	public abstract boolean isExist(Datasource dataSource) throws Exception;
}

 

package com.cvicse.report.ui.portal.impl;

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

import com.cvicse.inforreport.api.IReportDatasource;
import com.cvicse.inforreport.engine.ReportEngineFactory;
import com.cvicse.inforreport.model.datasource.Datasource;
import com.cvicse.report.ui.portal.api.IDataSource;

/**
 * 数据源操作的业务封装类
 * 
 * 采用单利模式进行封装
 * 
 */
public class DataSourceImpl implements IDataSource {

	private static IReportDatasource irds = ReportEngineFactory
			.getReportDatasource();// 数据源接口

	private final static IDataSource dataSourceImpl = new DataSourceImpl();

	/**
	 * 构造方法
	 */
	private DataSourceImpl() {

	}

	/**
	 * 获取单例实例模式
	 * 
	 * @return
	 */
	public static synchronized IDataSource getInstance() {
		return dataSourceImpl;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.cvicse.report.ui.impl.IdataSource#getAllDSList()
	 */
	public List<Datasource> getAllDSList() throws Exception {
		List<Datasource> templist = new ArrayList<Datasource>();
		templist = irds.getDSList();
		return templist;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.cvicse.report.ui.impl.IdataSource#getDSList(java.lang.String)
	 */
	public List<Datasource> getDSList(String type) throws Exception {
		List<Datasource> templist = new ArrayList<Datasource>();
		templist = irds.getDSList();
		List<Datasource> DBList = new ArrayList<Datasource>();
		for (Datasource datasource : templist) {
			if ((type.trim()).equals(datasource.getType())) {
				DBList.add(datasource);
			}
		}
		return DBList;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.cvicse.report.ui.impl.IdataSource#addDataSourc(com.cvicse.inforreport
	 * .model.datasource.Datasource)
	 */
	public void addDataSource(Datasource dataSource) throws Exception {
		irds.addDS(dataSource);
		irds.store();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.cvicse.report.ui.impl.IdataSource#deleteDataSource(com.cvicse.inforreport
	 * .model.datasource.Datasource)
	 */
	public void deleteDataSource(Datasource dataSource) throws Exception {
		irds.deleteDS(dataSource.getId().trim());
		irds.store();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.cvicse.report.ui.impl.IdataSource#editDataSource(com.cvicse.inforreport
	 * .model.datasource.Datasource)
	 */
	public void editDataSource(Datasource dataSource) throws Exception {
		irds.addDS(dataSource);
		irds.store();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.cvicse.report.ui.impl.IdataSource#testDataSource(com.cvicse.inforreport
	 * .model.datasource.Datasource)
	 */
	public String testDataSource(Datasource dataSource) throws Exception {
		try {
			String bool = irds.testDS(dataSource.getId().trim());
			if ("true".equals(bool)) {
				return "数据源连接成功。";
			} else {
				return "数据源连接失败,可能原因是: " + bool;
			}
		} catch (Exception e) {
			return "测试接口异常。";
		}
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.cvicse.report.ui.impl.IdataSource#isExist(com.cvicse.inforreport.
	 * model.datasource.Datasource)
	 */
	public boolean isExist(Datasource dataSource) throws Exception {
		return irds.exists(dataSource.getId());
	}
}

 

2、控制层bean的实现,在控制层添加了一个DBobject类做为辅助

package com.cvicse.report.ui.viewer.jsf.datasource;

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

import javax.faces.event.ActionEvent;

import com.cvicse.inforreport.model.datasource.DBDatasource;
import com.cvicse.inforreport.model.datasource.Datasource;
import com.cvicse.inforreport.model.datasource.ServerDatasource;
import com.cvicse.inforreport.model.datasource.TXTDatasource;
import com.cvicse.inforreport.model.datasource.WSDatasource;
import com.cvicse.report.ui.portal.api.IDataSource;
import com.cvicse.report.ui.portal.impl.DataSourceImpl;

/**
 *JDBC数据源Bean类
 * 
 */
public class DataSourceBean {

	private final static String JDBC_TYPE = "db";// jdbc数据源类型
	private final static String SERVER_TYPE = "server";// 服务器数据类型
	private final static String TXT_TYPE = "txt";// 文本数据类型
	private final static String WS_TYPE = "soap";// webservice数据类型

	private final static String JDBC_PAGE = "/pages/dataSource/includes/addJdbcType.xhtml"; // jdbc页面
	private final static String TXT_PAGE = "/pages/dataSource/includes/addTxtType.xhtml"; // TXT页面
	private final static String SERVER_PAGE = "/pages/dataSource/includes/addServerType.xhtml";// JNDI页面
	private final static String WS_PAGE = "/pages/dataSource/includes/addWSType.xhtml"; // webservice页面

	private final static String ORACLE_TPYE_4 = "Oracle Type 4";
	private final static String ORACLE_TPYE_4_DRIVERCLASS = "oracle.jdbc.driver.OracleDriver";
	private final static String ORACLE_TPYE_4_URL = "jdbc:oracle:thin:@host:1521:yourDB";
	private final static String ORACLE_OCI = "Oracle OCI";
	private final static String ORACLE_OCI_DRIVERCLASS = "oracle.jdbc.driver.OracleDriver";
	private final static String ORACLE_OCI_URL = "jdbc:oracle:oci8:@yourDB";
	private final static String DB2_TPYE_2 = "DB2 Type 2";
	private final static String DB2_TPYE_2_DRIVERCLASS = "COM.ibm.db2.jdbc.app.DB2Driver";
	private final static String DB2_TPYE_2_URL = "jdbc:db2:yourDB";
	private final static String DB2_TPYE_4 = "DB2 Type 4";
	private final static String DB2_TPYE_4_DRIVERCLASS = "COM.ibm.db2.jdbc.net.DB2Driver";
	private final static String DB2_TPYE_4_URL = "jdbc:db2://host:port/yourDB";
	private final static String MySQL = "MySQL";
	private final static String MySQL_DRIVERCLASS = "org.gjt.mm.mysql.Driver";
	private final static String MySQL_URL = "jdbc:mysql://host:3306/yourDB";
	private final static String MS_SQL_SERVER = "MS SQL Server";
	private final static String MS_SQL_SERVER_DRIVERCLASS = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
	private final static String MS_SQL_SERVER_URL = "jdbc:microsoft:sqlserver://host:1433;DatabaseName=yourDB";
	private final static String SYBASE = "Sybase";
	private final static String SYBASE_DRIVERCLASS = "com.sybase.jdbc2.jdbc.SybDriver";
	private final static String SYBASE_URL = "jdbc:sybase:Tds:host:port/yourDB";
	private final static String INFORMIX = "Informix";
	private final static String INFORMIX_DRIVERCLASS = "com.informix.jdbc.IfxDriver";
	private final static String INFORMIX_URL = "jdbc:informix-sqli://host:port/yourDB:informixserver=yourServer;user=username;password=password";
	private final static String HYPERSONIC_SQL = "Hypersonic SQL";
	private final static String HYPERSONIC_SQL_DRIVERCLASS = "org.hsqldb.jdbcDriver";
	private final static String HYPERSONIC_SQL_URL = "jdbc:hsqldb:hsql://host:1701";
	private final static String JDBC_ODBC = "JDBC-ODBC";
	private final static String JDBC_ODBC_DRIVERCLASS = "sun.jdbc.odbc.JdbcOdbcDriver";
	private final static String JDBC_ODBC_URL = "jdbc:odbc:odbcDS";

	private List<Datasource> dataSourceList = new ArrayList<Datasource>();// 数据源列表
	private IDataSource irds = DataSourceImpl.getInstance();// 数据源接口
	private Datasource selectedDataSource;// 选中数据源对象
	private DBDatasource addDBDataSource;// 新添加数据源
	private Datasource addTxtDataSource;// 新添文本数据源
	private Datasource addServerDataSource;// 新添server数据源
	private Datasource addWSDataSource;// 新添WS数据源

	private String dataSourceType;// 数据源类型
	private String drivertype;// 驱动的类型
	private String testResult;// 测试链接返回值信息

	private String pageSrc = JDBC_PAGE;// 页面路径地址

	private DBObject dbObject;// 存储驱动类和URL的临时对象

	/**
	 * 初始化数据源列表信息
	 */
	public DataSourceBean() {
		dataSourceList = this.getDBList();
	}

	/**
	 * 获取数据源列表
	 * 
	 * @return
	 */
	public List<Datasource> getDataSourceList() {
		return dataSourceList;
	}

	/**
	 * 添加数据源前初始化变量
	 */
	public void create() {
		// 初始化数据库类型
		this.dataSourceType = JDBC_TYPE;
		// 初始化DB数据库信息
		this.addDBDataSource = new DBDatasource();
		this.dbObject = new DBObject();
		this.drivertype = "";
		this.pageSrc = JDBC_PAGE;
		// 其他数据源更新信息
		this.addTxtDataSource = new TXTDatasource();// 新添文本数据源
		this.addServerDataSource = new ServerDatasource();// 新添server数据源
		this.addWSDataSource = new WSDatasource();// 新添WS数据源
	}

	/**
	 * 添加数据源
	 * 
	 * @return
	 */
	public void add() {
		try {
			if (JDBC_TYPE.equals(dataSourceType)) {
				addDBDataSource.setType(dataSourceType);
				addDBDataSource.setDriverClass(dbObject.getDriverClass());
				addDBDataSource.setUrl(dbObject.getUrl());
				addDBDataSource.setUser(dbObject.getUser());
				addDBDataSource.setPassword(dbObject.getPassword());
				irds.addDataSource(addDBDataSource);
			} else if (TXT_TYPE.equals(dataSourceType)) {
				addTxtDataSource.setType(dataSourceType);
				irds.addDataSource(addTxtDataSource);
			} else if (SERVER_TYPE.equals(dataSourceType)) {
				addServerDataSource.setType(dataSourceType);
				irds.addDataSource(addServerDataSource);
			} else if (WS_TYPE.equals(dataSourceType)) {
				addWSDataSource.setType(dataSourceType);
				irds.addDataSource(addWSDataSource);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		dataSourceList = this.getDBList();
	}

	/**
	 * 修改数据源
	 * 
	 * @param dataSource
	 */
	public void edit() {
		try {
			if (JDBC_TYPE.equals(selectedDataSource.getType())) {
				DBDatasource dbDatasource = (DBDatasource) selectedDataSource;
				dbDatasource.setDriverClass(dbObject.getDriverClass());
				dbDatasource.setUrl(dbObject.getUrl());
				dbDatasource.setUser(dbObject.getUser());
				dbDatasource.setPassword(dbObject.getPassword());
				irds.editDataSource(dbDatasource);
			} else {
				irds.editDataSource(selectedDataSource);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		dataSourceList = this.getDBList();
	}

	/**
	 * 删除数据源
	 * 
	 * @param dataSource
	 */
	public void delete() {
		try {
			irds.deleteDataSource(selectedDataSource);
		} catch (Exception e) {
			e.printStackTrace();
		}
		dataSourceList = this.getDBList();
	}

	/**
	 * 测试数据源
	 * 
	 * @return
	 */
	public void testConnection() {
		try {
			this.testResult = irds.testDataSource(selectedDataSource);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * 获取测试结果
	 * 
	 * @return
	 */
	public String getTestResult() {
		return testResult;
	}

	/**
	 * 设置测试结果
	 * 
	 * @param testResult
	 */
	public void setTestResult(String testResult) {
		this.testResult = testResult;
	}

	/**
	 * 获取添加DB类型对象
	 * 
	 * @return
	 */
	public Datasource getAddDBDataSource() {
		if (addDBDataSource == null) {
			addDBDataSource = new DBDatasource();
		}
		return addDBDataSource;
	}

	/**
	 * 设置DB类型对象
	 * 
	 * @param addDBDataSource
	 */
	public void setAddDBDataSource(DBDatasource addDBDataSource) {
		this.addDBDataSource = addDBDataSource;
	}

	/**
	 * 获取Txt类型添加对象
	 * 
	 * @return
	 */
	public Datasource getAddTxtDataSource() {
		if (addTxtDataSource == null) {
			addTxtDataSource = new TXTDatasource();
		}
		return addTxtDataSource;
	}

	/**
	 * 设置txt类型添加对象
	 * 
	 * @param addTxtDataSource
	 */
	public void setAddTxtDataSource(Datasource addTxtDataSource) {
		this.addTxtDataSource = addTxtDataSource;
	}

	/**
	 * 获取server类型数据源
	 * 
	 * @return
	 */
	public Datasource getAddServerDataSource() {
		if (addTxtDataSource == null) {
			addTxtDataSource = new ServerDatasource();
		}
		return addServerDataSource;
	}

	/**
	 * 设置server数据源
	 * 
	 * @param addServerDataSource
	 */
	public void setAddServerDataSource(Datasource addServerDataSource) {
		this.addServerDataSource = addServerDataSource;
	}

	/**
	 * 获取WS数据源
	 * 
	 * @return
	 */
	public Datasource getAddWSDataSource() {
		if (addTxtDataSource == null) {
			addTxtDataSource = new WSDatasource();
		}
		return addWSDataSource;
	}

	/**
	 * 设置ws数据源
	 * 
	 * @param addWSDataSource
	 */
	public void setAddWSDataSource(Datasource addWSDataSource) {
		this.addWSDataSource = addWSDataSource;
	}

	/**
	 * 获取其他数据源页面地址
	 * 
	 * @return
	 */
	public String getPageSrc() {
		return pageSrc;
	}

	/**
	 * 添加其他数据源页面地址
	 * 
	 * @param pageSrc
	 */
	public void setPageSrc(String pageSrc) {
		this.pageSrc = pageSrc;
	}

	/**
	 * 获取选择的数据源
	 * 
	 * @return
	 */
	public Datasource getSelectedDataSource() {
		return selectedDataSource;
	}

	/**
	 * 设置选择的数据源
	 * 
	 * @param selectedDataSource
	 */
	public void setSelectedDataSource(Datasource selectedDataSource) {
		if (JDBC_TYPE.equals(selectedDataSource.getType())) {
			// 在弹出的页面调用f:setPropertyActionListener调用get方法前,对原先的对象进行清空
			if (dbObject == null)
				dbObject = new DBObject();
			{
				drivertype = "";
				dbObject.setDriverClass(((DBDatasource) selectedDataSource)
						.getDriverClass());
				dbObject.setUrl(selectedDataSource.getUrl());
				dbObject.setUser(((DBDatasource) selectedDataSource).getUser());
				dbObject.setPassword(((DBDatasource) selectedDataSource)
						.getPassword());
			}
			this.selectedDataSource = selectedDataSource;
		} else if (SERVER_TYPE.equals(selectedDataSource.getType())) {
			this.selectedDataSource = selectedDataSource;
		} else if (TXT_TYPE.equals(selectedDataSource.getType())) {
			this.selectedDataSource = selectedDataSource;
		} else {
			this.selectedDataSource = selectedDataSource;
		}
	}

	/**
	 * 设置数据源类型
	 * 
	 * @param dataSourceType
	 */
	public void setDataSourceType(String dataSourceType) {
		this.dataSourceType = dataSourceType;
	}

	/**
	 * 获取数据源类型
	 * 
	 * @return
	 */
	public String getDataSourceType() {
		return dataSourceType;
	}

	/**
	 * 改变数据源类型
	 * 
	 * @param event
	 */
	public void changeDBSourceType(ActionEvent event) {
		if (JDBC_TYPE.equals(dataSourceType)) {
			pageSrc = JDBC_PAGE;
		} else if (SERVER_TYPE.equals(dataSourceType)) {
			pageSrc = SERVER_PAGE;
		} else if (TXT_TYPE.equals(dataSourceType)) {
			pageSrc = TXT_PAGE;
		} else if (WS_TYPE.equals(dataSourceType)) {
			pageSrc = WS_PAGE;
		}
	}

	/**
	 * 改变驱动类型
	 * 
	 * @param event
	 */
	public void changeDriverType(ActionEvent event) {
		if (ORACLE_TPYE_4.equals(drivertype)) {
			dbObject.setDriverClass(ORACLE_TPYE_4_DRIVERCLASS);
			dbObject.setUrl(ORACLE_TPYE_4_URL);
		} else if (ORACLE_OCI.equals(drivertype)) {
			dbObject.setDriverClass(ORACLE_OCI_DRIVERCLASS);
			dbObject.setUrl(ORACLE_OCI_URL);
		} else if (DB2_TPYE_2.equals(drivertype)) {
			dbObject.setDriverClass(DB2_TPYE_2_DRIVERCLASS);
			dbObject.setUrl(DB2_TPYE_2_URL);
		} else if (DB2_TPYE_4.equals(drivertype)) {
			dbObject.setDriverClass(DB2_TPYE_4_DRIVERCLASS);
			dbObject.setUrl(DB2_TPYE_4_URL);
		} else if (MySQL.equals(drivertype)) {
			dbObject.setDriverClass(MySQL_DRIVERCLASS);
			dbObject.setUrl(MySQL_URL);
		} else if (MS_SQL_SERVER.equals(drivertype)) {
			dbObject.setDriverClass(MS_SQL_SERVER_DRIVERCLASS);
			dbObject.setUrl(MS_SQL_SERVER_URL);
		} else if (SYBASE.equals(drivertype)) {
			dbObject.setDriverClass(SYBASE_DRIVERCLASS);
			dbObject.setUrl(SYBASE_URL);
		} else if (INFORMIX.equals(drivertype)) {
			dbObject.setDriverClass(INFORMIX_DRIVERCLASS);
			dbObject.setUrl(INFORMIX_URL);
		} else if (HYPERSONIC_SQL.equals(drivertype)) {
			dbObject.setDriverClass(HYPERSONIC_SQL_DRIVERCLASS);
			dbObject.setUrl(HYPERSONIC_SQL_URL);
		} else if (JDBC_ODBC.equals(drivertype)) {
			dbObject.setDriverClass(JDBC_ODBC_DRIVERCLASS);
			dbObject.setUrl(JDBC_ODBC_URL);
		} else {
			dbObject.setDriverClass("");
			dbObject.setUrl("");
		}
	}

	/**
	 * 获取驱动类型
	 * 
	 * @return
	 */
	public String getDrivertype() {
		return drivertype;
	}

	/**
	 * 设置驱动类型
	 * 
	 * @param drivertype
	 */
	public void setDrivertype(String drivertype) {
		if ("".equals(drivertype))
			this.drivertype = null;
		else
			this.drivertype = drivertype;
	}

	/**
	 * 获取当前对象
	 * 
	 * @return
	 */
	public DBObject getDbObject() {
		// 获取对象前判断对象是否为空,防止对象为空
		if (dbObject == null) {
			dbObject = new DBObject();
		}
		return dbObject;
	}

	/**
	 * 获取JDBC数据源所有的数据源
	 * 
	 * @return
	 */
	private List<Datasource> getDBList() {
		List<Datasource> DBList = new ArrayList<Datasource>();// JDBC数据源列表
		try {
			DBList = irds.getAllDSList();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return DBList;
	}
}

 

package com.cvicse.report.ui.viewer.jsf.datasource;

/**
 * 数据库对象类 在
 */
public class DBObject {
	private String driverClass;// 数据库驱动类
	private String url;// 数据库url地址
	private String user;// 用户名
	private String password;// 密码
	/**
	 * @return
	 */
	public String getDriverClass() {
		return driverClass;
	}
	/**
	 * @param driverClass
	 */
	public void setDriverClass(String driverClass) {
		this.driverClass = driverClass;
	}
	public String getUrl() {
		return url;
	}
	/**
	 * @param url
	 */
	public void setUrl(String url) {
		this.url = url;
	}
	/**
	 * @return
	 */
	public String getUser() {
		return user;
	}
	/**
	 * @param user
	 */
	public void setUser(String user) {
		this.user = user;
	}
	/**
	 * @return
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password
	 */
	public void setPassword(String password) {
		this.password = password;
	}
}

 

3、页面的展现设计,在展现过程中为了层次的清晰,我们分成了总体和部分页面的形式

(1)总体页面

   databasepannel.xml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 整体显示界面 -->
	<rich:tabPanel>
		<rich:tab label="数据源管理">
			<!-- 添加按钮 --> 
			<h:form
				style="margin:0;padding:0;">
				<div align="right">
				<a4j:commandButton id="addJdbcDataSourcBt"
					image="/images/icons/add.jpg" action="#{DBdataSourceBean.create}"
					oncomplete="#{rich:component('DataSourceAddPanel')}.show()" immediate="true"/>
				</div>
				<rich:toolTip for="addJdbcDataSourcBt">新建数据源</rich:toolTip>
				<a4j:keepAlive beanName="DBdataSourceBean" />
			</h:form> 
			<!-- 显示列表 --> 
			<ui:include
				src="/pages/dataSource/includes/list.xhtml" /> 
				<!-- 添加页面 --> 
				<ui:include
				src="/pages/dataSource/includes/add.xhtml" /> 
				<!-- 修改页面 --> 
				<ui:include
				src="/pages/dataSource/includes/editJdbcType.xhtml" /> 
				<ui:include
				src="/pages/dataSource/includes/editServerType.xhtml" /> 
				<ui:include
				src="/pages/dataSource/includes/editTxtType.xhtml" /> 
				<ui:include
				src="/pages/dataSource/includes/editWSType.xhtml" /> 
				<!-- 删除提示 -->
			<ui:include src="/pages/dataSource/includes/delete.xhtml" /> 
			<!-- 测试链接页面-->
			<ui:include src="/pages/dataSource/includes/testConection.xhtml" />
			<!-- 状态提示 --> <ui:include src="/pages/util/wait.xhtml" />
		</rich:tab>
	</rich:tabPanel>
</ui:composition>

 注意在总体页面中的添加按钮,添加过程中一定要把按钮方到form中才能有效的执行这个方法。

1、add.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 添加页面 -->
	<rich:modalPanel id="DataSourceAddPanel" autosized="true" width="450">
		<f:facet name="header">
			<h:outputText value="添加数据源" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/modal/close.png" id="DBAddHideLink"
					styleClass="hidelink" />
				<rich:componentControl for="DataSourceAddPanel"
					attachTo="DBAddHideLink" operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<rich:messages style="color:red;"></rich:messages>
			<h:panelGrid columns="1">
				<a4j:outputPanel ajaxRendered="true">
					<h:panelGrid id="addDBtype" columns="2">
						<h:outputText value="数据源类型:" />
						<h:selectOneMenu id="dbSourceType" style="width:250px"
							value="#{DBdataSourceBean.dataSourceType}" immediate="true">
							<a4j:support event="onchange"
								actionListener="#{DBdataSourceBean.changeDBSourceType}"/>
							<f:selectItem itemValue="db" itemLabel="db" />
							<f:selectItem itemValue="server" itemLabel="server" />
							<f:selectItem itemValue="txt" itemLabel="txt" />
							<f:selectItem itemValue="soap" itemLabel="soap" />
						</h:selectOneMenu>
						<ui:include src="#{DBdataSourceBean.pageSrc}"/>
					</h:panelGrid>
				</a4j:outputPanel>
			</h:panelGrid>
		</h:form>
	</rich:modalPanel>
</ui:composition>

 2、addJDBCType.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<h:outputText value="数据源名称:" />
	<h:inputText id="addJdbcNameInput"
		value="#{DBdataSourceBean.addDBDataSource.id}" style="width:250px"
		maxlength="50" />
	<h:outputText value="驱动类型:" />
	<h:selectOneMenu id="addJdbcDriverType" style="width:250px"
		value="#{DBdataSourceBean.drivertype}" immediate="true">
		<a4j:support event="onchange"
			actionListener="#{DBdataSourceBean.changeDriverType}"
			reRender="addJdbcDriverClassInput,addJdbcUrlInput" />
		<f:selectItem itemValue="" itemLabel="----------选择驱动类型----------" />
		<f:selectItem itemValue="Oracle Type 4" itemLabel="Oracle Type 4" />
		<f:selectItem itemValue="Oracle OCI" itemLabel="Oracle OCI" />
		<f:selectItem itemValue="DB2 Type 2" itemLabel="DB2 Type 2" />
		<f:selectItem itemValue="DB2 Type 4" itemLabel="DB2 Type 4" />
		<f:selectItem itemValue="MySQL" itemLabel="MySQL" />
		<f:selectItem itemValue="MS SQL Server" itemLabel="MS SQL Server" />
		<f:selectItem itemValue="Sybase" itemLabel="Sybase" />
		<f:selectItem itemValue="Informix" itemLabel="Informix" />
		<f:selectItem itemValue="Hypersonic SQL" itemLabel="Hypersonic SQL" />
		<f:selectItem itemValue="JDBC-ODBC" itemLabel="JDBC-ODBC" />
		<f:selectItem itemValue="other" itemLabel="other" />
	</h:selectOneMenu>

	<h:outputText value="驱动类:" />
	<h:inputText id="addJdbcDriverClassInput"
		value="#{DBdataSourceBean.dbObject.driverClass}" style="width:250px"
		maxlength="80" />

	<h:outputText value="URL:" />
	<h:inputText id="addJdbcUrlInput"
		value="#{DBdataSourceBean.dbObject.url}" style="width:250px"
		maxlength="80" />

	<h:outputText value="用户名:" />
	<h:inputText id="addJdbcUerInput"
		value="#{DBdataSourceBean.dbObject.user}" style="width:250px"
		maxlength="30" />

	<h:outputText value="密码:" />
	<h:inputSecret id="addJdbcPasswordInput"
		value="#{DBdataSourceBean.dbObject.password}" style="width:250px"
		maxlength="30" />

	<h:outputText value="备注:" />
	<h:inputText id="addJdbcDescriptionInput"
		value="#{DBdataSourceBean.addDBDataSource.description}"
		style="width:250px" maxlength="30" />
	<h:panelGrid columns="2">
		<a4j:commandButton value="添加" action="#{DBdataSourceBean.add}"
			reRender="DbdatasourceTableList"
			oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('DataSourceAddPanel')}.hide();" />
		<a4j:commandButton value="关闭"
			οnclick="#{rich:component('DataSourceAddPanel')}.hide();return false" />
	</h:panelGrid>
</ui:composition>

 

3、addServerType.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<h:outputText value="数据源名称:" />
	<h:inputText id="addTxtNameInput"
		value="#{DBdataSourceBean.addServerDataSource.id}" style="width:250px"
		maxlength="50" />
	<h:outputText value="JNDI名字:" />
	<h:inputText id="addServerUrlInput"
		value="#{DBdataSourceBean.addServerDataSource.url}" style="width:250px"
		maxlength="80" />
	<h:outputText value="备注:" />
	<h:inputText id="addServerDescriptionInput"
		value="#{DBdataSourceBean.addServerDataSource.description}"
		style="width:250px" maxlength="30" />
	<h:panelGrid columns="2">
		<a4j:commandButton value="添加" action="#{DBdataSourceBean.add}"
			reRender="DbdatasourceTableList"
			oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('DataSourceAddPanel')}.hide();" />
		<a4j:commandButton value="关闭"
			οnclick="#{rich:component('DataSourceAddPanel')}.hide();return false" />
	</h:panelGrid>
</ui:composition>

 

4、addTxtTpe.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<h:outputText value="数据源名称:" />
	<h:inputText id="addTxtNameInput"
		value="#{DBdataSourceBean.addTxtDataSource.id}" style="width:250px"
		maxlength="50" />
	<h:outputText value="路径:" />
	<h:inputText id="addTxtUrlInput"
		value="#{DBdataSourceBean.addTxtDataSource.url}" style="width:250px"
		maxlength="80" />
	<h:outputText value="备注:" />
	<h:inputText id="addTxtDescriptionInput"
		value="#{DBdataSourceBean.addTxtDataSource.description}"
		style="width:250px" maxlength="30" />
	<h:panelGrid columns="2">
		<a4j:commandButton value="添加" action="#{DBdataSourceBean.add}"
			reRender="DbdatasourceTableList"
			oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('DataSourceAddPanel')}.hide();" />
		<a4j:commandButton value="关闭"
			οnclick="#{rich:component('DataSourceAddPanel')}.hide();return false" />
	</h:panelGrid>
</ui:composition>

 

5、addWStype.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<h:outputText value="数据源名称:" />
	<h:inputText id="addsoapNameInput"
		value="#{DBdataSourceBean.addWSDataSource.id}" style="width:250px"
		maxlength="50" />
	<h:outputText value="SOAP URL:" />
	<h:inputText id="addsoapUrlInput"
		value="#{DBdataSourceBean.addWSDataSource.url}" style="width:250px"
		maxlength="80" />
	<h:outputText value="备注:" />
	<h:inputText id="addsoapDescriptionInput"
		value="#{DBdataSourceBean.addWSDataSource.description}"
		style="width:250px" maxlength="30" />
	<h:panelGrid columns="2">
		<a4j:commandButton value="添加" action="#{DBdataSourceBean.add}"
			reRender="DbdatasourceTableList"
			oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('DataSourceAddPanel')}.hide();" />
		<a4j:commandButton value="关闭"
			οnclick="#{rich:component('DataSourceAddPanel')}.hide();return false" />
	</h:panelGrid>
</ui:composition>

6、delete.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 删除提示 -->
	<rich:modalPanel id="jdbcDeletePanel" autosized="true" width="250"
		height="60" moveable="false" resizeable="false">
		<f:facet name="header">
			<h:outputText value="提示" style="padding-right:15px;" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/modal/close.png"
					styleClass="hidelink" id="jdbcDeleteHideLink" />
				<rich:componentControl for="jdbcDeletePanel" attachTo="jdbcDeleteHideLink"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<table width="100%">
				<tbody>
					<tr>
						<td colspan="2" align="center"><h:outputText
							value="确实要删除选中的列表?" /></td>
					</tr>
					<tr>
						<td align="center" width="50%"><a4j:commandButton value="确定"
							ajaxSingle="true" action="#{DBdataSourceBean.delete}"
							oncomplete="#{rich:component('jdbcDeletePanel')}.hide();"
							reRender="DbdatasourceTableList" /></td>
						<td align="center" width="50%"><a4j:commandButton value="取消"
							οnclick="#{rich:component('jdbcDeletePanel')}.hide();return false;" />
						</td>
					</tr>
				</tbody>
			</table>
		</h:form>
	</rich:modalPanel>
</ui:composition>

 

7.editJDBCType.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 修改页面 -->
	<rich:modalPanel id="dbEditPannal" autosized="true"
		width="450">
		<f:facet name="header">
			<h:outputText value="修改数据源" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/modal/close.png"
					id="dbEditHideLink" styleClass="hidelink" />
				<rich:componentControl for="dbEditPannal"
					attachTo="dbEditHideLink" operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<rich:messages style="color:red;"></rich:messages>
			<h:panelGrid columns="1">
				<a4j:outputPanel ajaxRendered="true">

					<h:panelGrid columns="2">
						<h:outputText value="名称:" />
						<h:inputText id="editdbNameInput"
							value="#{DBdataSourceBean.selectedDataSource.id}" disabled="true"
							style="width:250px" maxlength="50" />

						<h:outputText value="数据源类型:" />
						<h:inputText id="editdbTypeInput"
							value="#{DBdataSourceBean.selectedDataSource.type}"
							disabled="true" style="width:250px" maxlength="50" />

						<h:outputText value="驱动类型:" />
						<h:selectOneMenu id="editdbDriverType" style="width:250px"
							value="#{DBdataSourceBean.drivertype}" immediate="true">
							<a4j:support event="onchange"
								actionListener="#{DBdataSourceBean.changeDriverType}"
								reRender="editdbDriverClassInput,editdbUrlInput" />
							<f:selectItem itemValue="" itemLabel="----------选择驱动类型----------" />
							<f:selectItem itemValue="Oracle Type 4" itemLabel="Oracle Type 4" />
							<f:selectItem itemValue="Oracle OCI" itemLabel="Oracle OCI" />
							<f:selectItem itemValue="DB2 Type 2" itemLabel="DB2 Type 2" />
							<f:selectItem itemValue="DB2 Type 4" itemLabel="DB2 Type 4" />
							<f:selectItem itemValue="MySQL" itemLabel="MySQL" />
							<f:selectItem itemValue="MS SQL Server" itemLabel="MS SQL Server" />
							<f:selectItem itemValue="Sybase" itemLabel="Sybase" />
							<f:selectItem itemValue="Informix" itemLabel="Informix" />
							<f:selectItem itemValue="Hypersonic SQL"
								itemLabel="Hypersonic SQL" />
							<f:selectItem itemValue="db-ODBC" itemLabel="db-ODBC" />
							<f:selectItem itemValue="other" itemLabel="other" />
						</h:selectOneMenu>

						<h:outputText value="驱动类:" />
						<h:inputText id="editdbDriverClassInput"
							value="#{DBdataSourceBean.dbObject.driverClass}"
							style="width:250px" maxlength="80" />

						<h:outputText value="URL:" />
						<h:inputText id="editdbUrlInput"
							value="#{DBdataSourceBean.dbObject.url}" style="width:250px"
							maxlength="80" />

						<h:outputText value="用户名:" />
						<h:inputText id="editdbUerInput"
							value="#{DBdataSourceBean.dbObject.user}"
							style="width:250px" maxlength="30" />

						<h:outputText value="密码:" />
						<h:inputSecret id="editdbPasswordInput"
							value="#{DBdataSourceBean.dbObject.password}"
							style="width:250px" maxlength="30" redisplay="true"/>

						<h:outputText value="描述:" />
						<h:inputText id="editdbDescriptionInput"
							value="#{DBdataSourceBean.selectedDataSource.description}"
							style="width:250px" maxlength="30" />

						<h:panelGrid columns="2">
							<a4j:commandButton value="保存" action="#{DBdataSourceBean.edit}"
								reRender="DbdatasourceTableList"
								oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('dbEditPannal')}.hide();" />
							<a4j:commandButton value="关闭"
								οnclick="#{rich:component('dbEditPannal')}.hide();return false" />
						</h:panelGrid>
					</h:panelGrid>
				</a4j:outputPanel>
			</h:panelGrid>
		</h:form>
	</rich:modalPanel>
</ui:composition>

 

8、editServerType.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 修改页面 -->
	<rich:modalPanel id="serverEditPannal" autosized="true"
		width="450">
		<f:facet name="header">
			<h:outputText value="修改数据源" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/modal/close.png"
					id="serverEditHideLink" styleClass="hidelink" />
				<rich:componentControl for="serverEditPannal"
					attachTo="serverEditHideLink" operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<rich:messages style="color:red;"></rich:messages>
			<h:panelGrid columns="1">
				<a4j:outputPanel ajaxRendered="true">

					<h:panelGrid columns="2">
						<h:outputText value="名称:" />
						<h:inputText id="editserverNameInput"
							value="#{DBdataSourceBean.selectedDataSource.id}"
							disabled="true" style="width:250px" maxlength="50" />

						<h:outputText value="数据源类型:" />
						<h:inputText id="editserverTypeInput"
							value="#{DBdataSourceBean.selectedDataSource.type}"
							disabled="true" style="width:250px" maxlength="50" />

						<h:outputText value="JNDI名字:" />
						<h:inputText id="editserverUrlInput"
							value="#{DBdataSourceBean.selectedDataSource.url}"
							style="width:250px" maxlength="80" />

						<h:outputText value="描述:" />
						<h:inputText id="editserverDescriptionInput"
							value="#{DBdataSourceBean.selectedDataSource.description}"
							style="width:250px" maxlength="30" />

						<h:panelGrid columns="2">
							<a4j:commandButton value="保存"
								action="#{DBdataSourceBean.edit}"
								reRender="DbdatasourceTableList"
								oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('serverEditPannal')}.hide();" />
							<a4j:commandButton value="关闭"
								οnclick="#{rich:component('serverEditPannal')}.hide();return false" />
						</h:panelGrid>
					</h:panelGrid>
				</a4j:outputPanel>
			</h:panelGrid>
		</h:form>
	</rich:modalPanel>
</ui:composition>

 

9、editTxtType.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 修改页面 -->
	<rich:modalPanel id="txtEditPannal" autosized="true"
		width="450">
		<f:facet name="header">
			<h:outputText value="修改数据源" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/modal/close.png"
					id="txtEditHideLink" styleClass="hidelink" />
				<rich:componentControl for="txtEditPannal"
					attachTo="txtEditHideLink" operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<rich:messages style="color:red;"></rich:messages>
			<h:panelGrid columns="1">
				<a4j:outputPanel ajaxRendered="true">

					<h:panelGrid columns="2">
						<h:outputText value="名称:" />
						<h:inputText id="edittxtNameInput"
							value="#{DBdataSourceBean.selectedDataSource.id}"
							disabled="true" style="width:250px" maxlength="50" />

						<h:outputText value="数据源类型:" />
						<h:inputText id="edittxtTypeInput"
							value="#{DBdataSourceBean.selectedDataSource.type}"
							disabled="true" style="width:250px" maxlength="50" />

						<h:outputText value="URL路径:" />
						<h:inputText id="edittxtUrlInput"
							value="#{DBdataSourceBean.selectedDataSource.url}"
							style="width:250px" maxlength="80" />

						<h:outputText value="描述:" />
						<h:inputText id="edittxtDescriptionInput"
							value="#{DBdataSourceBean.selectedDataSource.description}"
							style="width:250px" maxlength="30" />

						<h:panelGrid columns="2">
							<a4j:commandButton value="保存"
								action="#{DBdataSourceBean.edit}"
								reRender="DbdatasourceTableList"
								oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('txtEditPannal')}.hide();" />
							<a4j:commandButton value="关闭"
								οnclick="#{rich:component('txtEditPannal')}.hide();return false" />
						</h:panelGrid>
					</h:panelGrid>
				</a4j:outputPanel>
			</h:panelGrid>
		</h:form>
	</rich:modalPanel>
</ui:composition>

 

10.editWSType.xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 修改页面 -->
	<rich:modalPanel id="soapEditPannal" autosized="true"
		width="450">
		<f:facet name="header">
			<h:outputText value="修改数据源" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/modal/close.png"
					id="soapEditHideLink" styleClass="hidelink" />
				<rich:componentControl for="soapEditPannal"
					attachTo="soapEditHideLink" operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<rich:messages style="color:red;"></rich:messages>
			<h:panelGrid columns="1">
				<a4j:outputPanel ajaxRendered="true">

					<h:panelGrid columns="2">
						<h:outputText value="名称:" />
						<h:inputText id="editsoapNameInput"
							value="#{DBdataSourceBean.selectedDataSource.id}"
							disabled="true" style="width:250px" maxlength="50" />

						<h:outputText value="数据源类型:" />
						<h:inputText id="editsoapTypeInput"
							value="#{DBdataSourceBean.selectedDataSource.type}"
							disabled="true" style="width:250px" maxlength="50" />

						<h:outputText value="SOAP地址:" />
						<h:inputText id="editsoapUrlInput"
							value="#{DBdataSourceBean.selectedDataSource.url}"
							style="width:250px" maxlength="80" />

						<h:outputText value="描述:" />
						<h:inputText id="editsoapDescriptionInput"
							value="#{DBdataSourceBean.selectedDataSource.description}"
							style="width:250px" maxlength="30" />

						<h:panelGrid columns="2">
							<a4j:commandButton value="保存"
								action="#{DBdataSourceBean.edit}"
								reRender="DbdatasourceTableList"
								oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('soapEditPannal')}.hide();" />
							<a4j:commandButton value="关闭"
								οnclick="#{rich:component('soapEditPannal')}.hide();return false" />
						</h:panelGrid>
					</h:panelGrid>
				</a4j:outputPanel>
			</h:panelGrid>
		</h:form>
	</rich:modalPanel>
</ui:composition>

 

11、list。xhtml

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 显示列表页面 -->
	<h:form>
		<rich:dataTable id="DbdatasourceTableList"
			onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
			onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
			cellpadding="0" cellspacing="0" width="100%" border="0"
			value="#{DBdataSourceBean.dataSourceList}" var="jdbcDataSource">
			<f:facet name="header">
				<h:outputText value="数据源列表" />
			</f:facet>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="名称" />
				</f:facet>
				<h:outputText id="jdbcName" value="#{jdbcDataSource.id}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="类型" />
				</f:facet>
				<h:graphicImage
				value="/images/icons/#{jdbcDataSource.type}.png"/>
				<h:outputText id="jdbcType" value="#{jdbcDataSource.type}" />
			</rich:column>
			<rich:column width="40%"
				style="word-wrap: break-word; word-break: break-all;">
				<f:facet name="header">
					<h:outputText value="URL地址" />
				</f:facet>
				<h:outputText id="jdbcUrl" value="#{jdbcDataSource.url}" />
			</rich:column>
			<rich:column>
				<f:facet name="header">
					<h:outputText value="描述" />
				</f:facet>
				<h:outputText id="jdbcDescription"
					value="#{jdbcDataSource.description}" />
			</rich:column>
			<rich:column width="95">
				<f:facet name="header">
					<h:outputText value="操作" />
				</f:facet>
				<a4j:commandLink ajaxSingle="true" id="editForJdbcLink"
					oncomplete="Richfaces.showModalPanel('#{DBdataSourceBean.selectedDataSource.type}'+'EditPannal');"
					style="margin-left:10;margin-right:5;">
					<h:graphicImage value="/images/icons/database_edit.png"
						style="border:0" />
					<f:setPropertyActionListener value="#{jdbcDataSource}"
						target="#{DBdataSourceBean.selectedDataSource}" />
				</a4j:commandLink>
				<rich:toolTip for="editForJdbcLink">修改数据源</rich:toolTip>

				<a4j:commandLink ajaxSingle="true" id="deleteForJdbcLink"
					oncomplete="#{rich:component('jdbcDeletePanel')}.show()"
					style="margin-left:5;margin-right:5;">
					<h:graphicImage value="/images/icons/database_delete.png"
						style="border:0" />
					<f:setPropertyActionListener value="#{jdbcDataSource}"
						target="#{DBdataSourceBean.selectedDataSource}" />
				</a4j:commandLink>
				<rich:toolTip for="deleteForJdbcLink">删除数据源</rich:toolTip>
				<a4j:keepAlive beanName="DBdataSourceBean" />

				<a4j:commandLink ajaxSingle="true" id="testForJdbcLink"
					action="#{DBdataSourceBean.testConnection}"
					oncomplete="#{rich:component('testJdbcConectionPanel')}.show()"
					reRender="testJdbcData" style="margin-left:5;margin-right:10;">
					<h:graphicImage value="/images/icons/database_connect.png"
						style="border:0" />
					<f:setPropertyActionListener value="#{jdbcDataSource}"
						target="#{DBdataSourceBean.selectedDataSource}" />
				</a4j:commandLink>
				<rich:toolTip for="testForJdbcLink">测试数据源</rich:toolTip>
				<a4j:keepAlive beanName="DBdataSourceBean" />
			</rich:column>
		</rich:dataTable>
	</h:form>
</ui:composition>

 

在list中的修改时,注意一定要keepalive标签,另外,不同的类型展现不同的修改页面也一定要记住这种写法。另外,图形表面的图标在页面中的加载方式的写法也要注意。

12、testConenction。xhtml的xhtml页

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">
	<!-- 测试提示 -->
	<rich:modalPanel id="testJdbcConectionPanel" autosized="true" width="250"
		height="100" moveable="false" resizeable="false">
		<f:facet name="header">
			<h:outputText value="提示" style="padding-right:15px;" />
		</f:facet>
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/images/modal/close.png"
					styleClass="hidelink" id="testJdbcHideLink" />
				<rich:componentControl for="testJdbcConectionPanel" attachTo="testJdbcHideLink"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		<h:form>
			<table width="100%">
				<tbody>
					<tr>
						<td align="center"><h:outputText
							value="#{DBdataSourceBean.testResult}" id="testJdbcData" /></td>
					</tr>
					<tr>
						<td align="center"><a4j:commandButton value="关闭"
							οnclick="#{rich:component('testJdbcConectionPanel')}.hide();return false;" />
						</td>
					</tr>
				</tbody>
			</table>
		</h:form>
	</rich:modalPanel>
</ui:composition>

 

总结:自己做的东西,在摸索中会遇到很多的知识,通过这个方法自己能更清楚的了解其中的原理。不过,在闲暇的时间要返回头去看看基础,会有更清楚的认识。

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
目标检测(Object Detection)是计算机视觉领域的一个核心问题,其主要任务是找出图像中所有感兴趣的目标(物体),并确定它们的类别和位置。以下是对目标检测的详细阐述: 一、基本概念 目标检测的任务是解决“在哪里?是什么?”的问题,即定位出图像中目标的位置并识别出目标的类别。由于各类物体具有不同的外观、形状和姿态,加上成像时光照、遮挡等因素的干扰,目标检测一直是计算机视觉领域最具挑战性的任务之一。 二、核心问题 目标检测涉及以下几个核心问题: 分类问题:判断图像中的目标属于哪个类别。 定位问题:确定目标在图像中的具体位置。 大小问题:目标可能具有不同的大小。 形状问题:目标可能具有不同的形状。 三、算法分类 基于深度学习的目标检测算法主要分为两大类: Two-stage算法:先进行区域生成(Region Proposal),生成有可能包含待检物体的预选框(Region Proposal),再通过卷积神经网络进行样本分类。常见的Two-stage算法包括R-CNN、Fast R-CNN、Faster R-CNN等。 One-stage算法:不用生成区域提议,直接在网络中提取特征来预测物体分类和位置。常见的One-stage算法包括YOLO系列(YOLOv1、YOLOv2、YOLOv3、YOLOv4、YOLOv5等)、SSD和RetinaNet等。 四、算法原理 以YOLO系列为例,YOLO将目标检测视为回归问题,将输入图像一次性划分为多个区域,直接在输出层预测边界框和类别概率。YOLO采用卷积网络来提取特征,使用全连接层来得到预测值。其网络结构通常包含多个卷积层和全连接层,通过卷积层提取图像特征,通过全连接层输出预测结果。 五、应用领域 目标检测技术已经广泛应用于各个领域,为人们的生活带来了极大的便利。以下是一些主要的应用领域: 安全监控:在商场、银行
目标检测(Object Detection)是计算机视觉领域的一个核心问题,其主要任务是找出图像中所有感兴趣的目标(物体),并确定它们的类别和位置。以下是对目标检测的详细阐述: 一、基本概念 目标检测的任务是解决“在哪里?是什么?”的问题,即定位出图像中目标的位置并识别出目标的类别。由于各类物体具有不同的外观、形状和姿态,加上成像时光照、遮挡等因素的干扰,目标检测一直是计算机视觉领域最具挑战性的任务之一。 二、核心问题 目标检测涉及以下几个核心问题: 分类问题:判断图像中的目标属于哪个类别。 定位问题:确定目标在图像中的具体位置。 大小问题:目标可能具有不同的大小。 形状问题:目标可能具有不同的形状。 三、算法分类 基于深度学习的目标检测算法主要分为两大类: Two-stage算法:先进行区域生成(Region Proposal),生成有可能包含待检物体的预选框(Region Proposal),再通过卷积神经网络进行样本分类。常见的Two-stage算法包括R-CNN、Fast R-CNN、Faster R-CNN等。 One-stage算法:不用生成区域提议,直接在网络中提取特征来预测物体分类和位置。常见的One-stage算法包括YOLO系列(YOLOv1、YOLOv2、YOLOv3、YOLOv4、YOLOv5等)、SSD和RetinaNet等。 四、算法原理 以YOLO系列为例,YOLO将目标检测视为回归问题,将输入图像一次性划分为多个区域,直接在输出层预测边界框和类别概率。YOLO采用卷积网络来提取特征,使用全连接层来得到预测值。其网络结构通常包含多个卷积层和全连接层,通过卷积层提取图像特征,通过全连接层输出预测结果。 五、应用领域 目标检测技术已经广泛应用于各个领域,为人们的生活带来了极大的便利。以下是一些主要的应用领域: 安全监控:在商场、银行
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值