`

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="关闭"
			onclick="#{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="关闭"
			onclick="#{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="关闭"
			onclick="#{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="关闭"
			onclick="#{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="取消"
							onclick="#{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="关闭"
								onclick="#{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="关闭"
								onclick="#{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="关闭"
								onclick="#{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="关闭"
								onclick="#{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="关闭"
							onclick="#{rich:component('testJdbcConectionPanel')}.hide();return false;" />
						</td>
					</tr>
				</tbody>
			</table>
		</h:form>
	</rich:modalPanel>
</ui:composition>

 

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

 

 

 

 

 

  • 大小: 68 KB
分享到:
评论

相关推荐

    使用richfaces 实现tree

    本教程将聚焦于如何使用RichFaces实现一个动态的树形视图。 首先,我们需要确保开发环境已经配置了以下组件: 1. JDK 1.5:这是运行JSF和RichFaces的基础,确保已安装并设置好`JAVA_HOME`环境变量。 2. JSF 1.2.*:...

    richfaces实现ajax带进度条的上传

    本教程将详细讲解如何利用RichFaces实现带有进度条的AJAX文件上传。 首先,让我们了解RichFaces的核心特性。RichFaces是一个开源项目,它扩展了JSF标准,提供了许多高级组件,如数据网格、日期选择器、树形视图等。...

    RichFaces中的ajax组件实现刷新验证码

    在探讨“RichFaces中的ajax组件实现刷新验证码”的技术细节时,我们首先需要理解RichFaces框架以及AJAX在其中的应用。RichFaces是一个基于JavaServer Faces(JSF)的开源UI组件库,它提供了丰富的用户界面组件,包括...

    richfaces-ui-3.2.1

    在标签中提到的“ajax”和“ajax4jsf”,它们是RichFaces实现AJAX功能的关键。AJAX技术允许Web应用在后台与服务器进行异步通信,用户可以在不离开当前页面的情况下获取和提交数据。而AJAX4JSF是RichFaces提供的一个...

    richfaces详细使用

    1. **页面级别的Ajax支持**:不同于传统框架仅提供组件级的Ajax功能,RichFaces实现了页面级别的Ajax化。这意味着一个事件触发的Ajax请求能够同步更新整个页面的部分区域,而非仅仅影响单个组件,大大提升了操作效率...

    richfaces自动构建树实现.docx

    RichFaces 自动构建树实现 RichFaces 自动构建树实现是基于 Java 语言和 RichFaces 框架的树形结构实现。树形结构在软件系统中非常常见,包括树形菜单的构建、基于二叉树的二分查找法等等。RichFaces 提供了树形...

    richfaces4.0所需jar包

    1. **richfaces-components-ui-4.0.0.Final.jar**:这是RichFaces组件用户界面实现的库。它包含了一系列的JSF组件,如表格、树形视图、滑块、日期选择器等。这些组件提供了丰富的功能和样式,使得开发者能够轻松创建...

    richfaces中文开发文档

    **RichFaces中文开发文档概述** RichFaces是一款基于JavaServer Faces(JSF)技术的开源UI组件库,由JBoss组织开发。它为JSF应用程序提供了丰富的用户体验和强大的交互功能。这款框架极大地简化了Web开发过程,尤其...

    jsf/RichFaces组件

    RichFaces组件简介,复合组件,日期控件,Ajax标签, 轻松实现。RichFaces组件简介,复合组件,日期控件,Ajax标签, 轻松实现。RichFaces组件简介,复合组件,日期控件,Ajax标签, 轻松实现。

    RichFaces4.5 JavaApi JSApi

    例如,`org.richfaces.component.UIAjaxBehavior`接口允许开发者添加异步行为到JSF组件,实现AJAX功能。此外,`org.richfaces.model.SelectItem`类用于创建可选的下拉框或列表项,提供更灵活的数据绑定选项。`org....

    RichFaces 3.3 帮助文档(英文)

    ### RichFaces 3.3 帮助文档关键知识点概览 #### 一、简介 - **RichFaces框架概述:** RichFaces是一个基于JavaServer Faces(JSF)的开源组件库,提供了大量的富客户端组件以及对皮肤的支持。该文档详细介绍了如何...

    Richfaces标签

    Richfaces提供的组件极大地简化了Web应用开发过程中的UI设计工作,使得开发者能够更专注于业务逻辑的实现。通过对上述标签的学习和理解,我们可以更好地利用Richfaces来提升项目的交互性和用户体验。

    Richfaces ShowCase离线包

    **Richfaces ShowCase离线包** 是一个专为开发者设计的资源包,它包含了Richfaces框架的演示示例,能够帮助用户在没有网络连接的情况下也能深入理解和学习Richfaces的功能和用法。这个离线包特别适合那些需要在本地...

    Richfaces组件使用指南

    2. 支持的JSF实现,如Sun JSF-RI 1.2_x或2.x,MyFaces 1.2.x或2.x。 3. Java应用程序服务器或Servlet容器,如Apache Tomcat 5.5至6.0。 总的来说,RichFaces为开发者提供了一个强大的工具集,用于构建具有丰富交互...

    richfaces开发指南(英文版)

    - **JavaServer Faces实现和框架**:RichFaces设计为与多种JSF实现和框架兼容,例如MyFaces、Mojarra等。请确认你的项目使用的JSF实现与RichFaces兼容。 - **支持的服务器**:RichFaces可在多个应用服务器上运行,如...

    richfaces3.2用户手册的pdf版

    - **支持的JavaServer Faces实现和框架**:为了确保与JSF 的良好集成,RichFaces 需要与特定的JSF 实现和框架进行配合使用,例如Sun JSF RI 和Apache MyFaces。 - **支持的服务器**:RichFaces 3.2 可以在多种应用...

    richfaces参考文档

    1. **AJAX 支持**:RichFaces 使用 A4J (Ajax for Java) 技术,允许开发者通过简单的声明式或编程方式实现页面局部更新,减少页面重载,提升响应速度。 2. **组件库**:包括各种富组件,如数据表(DataTable)、...

    richfaces-3.0.0

    9. **源码学习:** 通过分析 "jboss-richfaces-3.0.0-src" 中的源码,开发者可以学习 RichFaces 如何实现其组件和功能,了解底层机制。 10. **开发实践:** API 文档和源码结合使用,可以帮助开发者更深入地理解 ...

Global site tag (gtag.js) - Google Analytics