??xml version="1.0" encoding="utf-8" standalone="yes"?>91电影在线播放,亚洲成人1区,日韩欧美一级片http://www.aygfsteel.com/hnicypb/category/34332.html登高者必自卑Q行q者必自迩Q在q个世界上,重要的不是你正站在那里,而是你正朝什么方向移?..... zh-cnTue, 09 Sep 2008 02:28:15 GMTTue, 09 Sep 2008 02:28:15 GMT60JSF入门与提高目录(有实例子Q?http://www.aygfsteel.com/hnicypb/articles/227874.htmlSky YiSky YiTue, 09 Sep 2008 02:21:00 GMThttp://www.aygfsteel.com/hnicypb/articles/227874.htmlhttp://www.aygfsteel.com/hnicypb/comments/227874.htmlhttp://www.aygfsteel.com/hnicypb/articles/227874.html#Feedback0http://www.aygfsteel.com/hnicypb/comments/commentRss/227874.htmlhttp://www.aygfsteel.com/hnicypb/services/trackbacks/227874.html入门
藉由以下的几个主题,可以大致了解JSF的轮廓与Ҏ(gu),我们来看看网设计h员与应用E序设计人员各负责什么?br /> o 介JSF
o W一个JSFE序
o 单的D Navigation
o D规则讄
o JSF Expression Language
o 国际化讯?/a>
Managed Beans
JSF 使用 Bean 来达到逻辑层与表现层分ȝ目的QBean 的管理集中在l态档案中Q?zhn)只要修改l态档案,可以修?Bean 之间的相依关pR?br /> o
Backing Beans
o Beans 的组态与讑֮
o Beans 上的 List, Map
数据转换与验?/strong>
转换器(ConverterQ协助模型与视图之间的数据{换,验证器(ValidatorQ协助进行语意检验(Semantic ValidationQ?br /> o 标准转换?/a>
o
自订转换?/a>
o
标准验证?/a>
o
自订验证?/a>
o
错误讯息处理
o 自订转换, 验证标签
事g处理
JSF的事件模型提供一个近似的桌面GUI事g模式Q让熟?zhn)GUI设计的h员也能快速上手WebE序设计?br /> o 动作事g
o 实时事g
o 值变事g
o Phase 事g
 JSF 标签

  |页设计人员要作的就是了解JSF的标{使用方式Q这像是学习进阶的HTML标签Q另一件事是与程序设计h员沟通好各个Bean的名U绑定?/p>

标签入门
h的相兛_性查询,(zhn)可以参?Tag Library DocumentationQ这边的介绍只是一些简单的入门实例?br /> o 介JSF标准标签
o 输出cL{?/a>
o
输入cL{?/a>
o
命ocL{?/a>
o
选择cL{?一
o 选择cL{??/a>
o
其它标签
表格处理
对于必须使用表格方式呈现的数据,JSF ?<h:dataTable> h协助(zhn)进行动态表格数据的输出?br /> o 单的表格
o 表头, 表尾
o TableModel cd
 自订lg

  JSF 让?zhn)可以自订lgQ每个组仉是可替换的,q得组件在搭配时更有弹性,但相对的却开发组件的q程复杂的多Q这边对自订JSF lg只是个入门砖Q更多有兌订组件的l节可得要专书来说明?/p>

JSF 生命周期与组件概q?/strong>
要开?JSF lgQ?zhn)需要更深入了解 JSF 的一些处理细节,包括?JSF 生命周期以及 JSF 框架?br /> o JSF 生命周期
o 概述自订lg
单实?/strong>
在不考虑lg有子lg的情况下Q这边以实际的一个例子来说明开发组件的q程Q至于考虑子组件的情况请参考专书介l?br /> o ~码, 译码
o lgh
o 使用自订lg
o 自订 Renderer

 



Sky Yi 2008-09-09 10:21 发表评论
]]>
数据库操作管理类http://www.aygfsteel.com/hnicypb/articles/226725.htmlSky YiSky YiWed, 03 Sep 2008 09:19:00 GMThttp://www.aygfsteel.com/hnicypb/articles/226725.htmlhttp://www.aygfsteel.com/hnicypb/comments/226725.htmlhttp://www.aygfsteel.com/hnicypb/articles/226725.html#Feedback0http://www.aygfsteel.com/hnicypb/comments/commentRss/226725.htmlhttp://www.aygfsteel.com/hnicypb/services/trackbacks/226725.html 

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import org.apache.log4j.Logger;

/**
 * 数据库操作管理类
 *
 * @author Harlyhood
 *
 */
public class DBManager {

 // --------------------------------------------------------- Instance
 private static Logger logger = Logger.getLogger(DBManager.class);
 // --------------------------------------------------------- Methods

 // 数据库连接对?br />  private Connection con;
 // SQL语句对象
 private Statement stmt;
 // 带参数的Sql语句对象
 private PreparedStatement pstmt;
 // 记录集对?br />  private ResultSet rs;
 // 数据q接理Q连接池对象Q?br />  private DBConnectionManager dcm = null;

 /** ***********************手动讄的连接参?******************************** */
 @SuppressWarnings("unused")
 private static String _DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
 @SuppressWarnings("unused")
 private static String _URL = "jdbc:sqlserver://localhost:1433;database=Hospital_AI_DB;characterEncoding=gb2312";
 @SuppressWarnings("unused")
 private static String _USER_NA = "sa";
 @SuppressWarnings("unused")
 private static String _PASSWORD = "";

 /** ********************************************************************** */

 // 默认构?br />  public DBManager() {
 }

 /** ****************************************************************************************** */
 /**
  * **************************************** 数据库连接初始化
  * ***********************************
  */
 /** ****************************************************************************************** */

 /**
  * 得到一个默认的数据库连接[?com.hospital.dao.tools.db.properties文g初始化]
  *
  * @throws Exception
  */
 private void getConnection() {
  logger.info("###############open:::::从默认的配置文g得到一个数据库q接");
  // 获取一个连接池理cȝ实例
  dcm = DBConnectionManager.getInstance();
  // 得到一个数据库q接
  con = dcm.getConnection("mysql");

  try {
   con.setAutoCommit(false);
  } catch (SQLException e) {

   e.printStackTrace();
  }
 }

 /**
  * 从指定参数得C个连接对?br />   *
  * @param driver
  * @param url
  * @param user_na
  * @param password
  * @throws Exception
  */
 public void getConnection(String driver, String url, String user_na,
   String password) throws Exception {
  try {
   logger.info("###############open:::::从指定配|中得到一个数据库q接");
   Class.forName(driver);
   con = DriverManager.getConnection(url, user_na, password);
  } catch (ClassNotFoundException ex) {
   logger
     .info("###############Error[com.hospital.dao.tools.DBManager^^^Method:getConnection^^^Line:81]找不到类驱动c? "
       + driver);
   throw ex;
  } catch (SQLException ex) {
   logger
     .info("###############Error[com.hospital.dao.tools.DBManager^^^Method:getConnection^^^Line:81]加蝲c? "
       + driver + " 时出?SQLException 异常");
   throw ex;
  }
 }

 /** ****************************************************************************************** */
 /**
  * **************************************** 数据库操作方?br />   * ***********************************
  */
 /** ****************************************************************************************** */

 /**
  * 执行SQL语句操作(更新数据 无参?
  *
  * @param strSql
  *            SQL语句
  * @throws Exception
  */
 public boolean executeUpdate(String strSql) throws SQLException {
  getConnection();
  // getConnection(_DRIVER,_URL,_USER_NA,_PASSWORD);
  boolean flag = false;
  stmt = con.createStatement();
  logger.info("###############::执行SQL语句操作(更新数据 无参?:" + strSql);
  try {
   if (0 < stmt.executeUpdate(strSql)) {
    close_DB_Object();
    flag = true;
    con.commit();
   }
  } catch (SQLException ex) {
   logger
     .info("###############Error DBManager Line126::执行SQL语句操作(更新数据 无参?:"
       + strSql + "p|!");
   flag = false;
   con.rollback();
   throw ex;
  }
  return flag;

 }

 /**
  * 执行SQL语句操作(更新数据 有参?
  *
  * @param strSql
  *            sql指o
  * @param prams
  *            参数列表
  * @return
  * @throws SQLException
  */
 public boolean executeUpdate(String strSql, HashMap<Integer, Object> prams)
   throws SQLException, ClassNotFoundException {
  getConnection();
  // getConnection(_DRIVER,_URL,_USER_NA,_PASSWORD);
  boolean flag = false;
  try {
   pstmt = con.prepareStatement(strSql);
   setParamet(pstmt, prams);
   logger.info("###############::执行SQL语句操作(更新数据 有参?:" + strSql);

   if (0 < pstmt.executeUpdate()) {
    close_DB_Object();
    flag = true;
    con.commit();
   }
  } catch (SQLException ex) {
   logger
     .info("###############Error DBManager Line121::执行SQL语句操作(更新数据 无参?:"
       + strSql + "p|!");
   flag = false;
   con.rollback();
   throw ex;
  } catch (ClassNotFoundException ex) {
   logger
     .info("###############Error DBManager Line152::执行SQL语句操作(更新数据 无参?:"
       + strSql + "p|! 参数讄cd错误!");
   con.rollback();
   throw ex;
  }
  return flag;

 }

 /**
  * 执行SQL语句操作(查询数据 无参?
  *
  * @param strSql
  *            SQL语句
  * @return 数组对象列表
  * @throws Exception
  */
 public ArrayList<HashMap<Object, Object>> executeSql(String strSql)
   throws Exception {
  getConnection();
  // getConnection(_DRIVER,_URL,_USER_NA,_PASSWORD);
  stmt = con.createStatement();
  logger.info("###############::执行SQL语句操作(查询数据):" + strSql);
  rs = stmt.executeQuery(strSql);
  con.commit();
  if (null != rs) {
   return convertResultSetToArrayList(rs);
  }
  close_DB_Object();
  return null;
 }

 /**
  * 执行SQL语句操作(查询数据 有参?
  *
  * @param strSql
  *            SQL语句
  * @param prams
  *            参数列表
  * @return 数组对象列表
  * @throws Exception
  */
 public ArrayList<HashMap<Object, Object>> executeSql(String strSql,
   HashMap<Integer, Object> prams) throws Exception {
  getConnection();
  // getConnection(_DRIVER,_URL,_USER_NA,_PASSWORD);
  pstmt = con.prepareStatement(strSql);
  setParamet(pstmt, prams);
  logger.info("###############::执行SQL语句操作(查询数据):" + strSql);
  rs = pstmt.executeQuery();
  con.commit();
  if (null != rs) {
   return convertResultSetToArrayList(rs);
  }
  return null;
 }

 /**
  * 执行存储q程(查询数据 无参?
  *
  * @param procName
  *            存储q程名称
  * @return 数组列表对象
  * @throws Exception
  */
 public ArrayList<HashMap<Object, Object>> executeProcedureQuery(
   String procName) throws Exception {
  getConnection();// 获取q接
  String callStr = "{call " + procName + "}";// 构造执行存储过E的sql指o
  CallableStatement cs = con.prepareCall(callStr);
  logger.info("###############::执行存储q程(查询数据):" + procName);
  rs = cs.executeQuery();
  con.commit();
  cs.close();
  close_DB_Object();
  return convertResultSetToArrayList(rs);
 }

 /**
  * 执行存储q程(查询数据,带参?q回l果集合
  *
  * @param procName
  *            存储q程名称
  * @param parameters
  *            参数对象数组
  * @param al
  *            数组列表对象
  * @return 数组列表对象
  * @throws Exception
  */
 public ArrayList<HashMap<Object, Object>> executeProcedureQuery(
   String procName, Object[] parameters) throws Exception {
  int parameterPoint = 0;
  // 获取存储q程信息列表集合
  ArrayList<HashMap<Object, Object>> procedureInfo = getProcedureInfo(procName);
  // 获取存储q程的完全名U?br />   String procedureCallName = getProcedureCallName(procName,parameters.length);
  // 获取q接对象
  getConnection();
  // 初始?存储q程 执行对象
  CallableStatement cs = con.prepareCall(procedureCallName);
  // 参数下标变量
  int index = 0;
  // 获取 存储q程信息列表集合?q代?对象
  Iterator<HashMap<Object, Object>> iter = procedureInfo.iterator();
  // 遍历存储q程信息列表集合
  while (iter.hasNext()) {
   HashMap<Object, Object> hm = iter.next();

   parameterPoint++;
   // 如果参数是输入参?way = 0
   if (hm.get("WAY").equals("0")) {
    // 讄参数到cs
    cs.setObject(parameterPoint, parameters[index]);
    // 参数下标+1
    index++;
   }
  }
  // 释放q个对象,做ؓW二ơ?br />   procedureInfo = null;
  logger.info("###############::执行存储q程(查询数据):::::" + procedureCallName);
  rs = cs.executeQuery();
  con.commit();
  procedureInfo = convertResultSetToArrayList(rs);
  cs.close();
  close_DB_Object();
  return procedureInfo;

 }

 /**
  * 执行存储q程(更新Q查询数据[单查询、非U录集]Q返回输出参数[非纪录集])
  *
  * @param procName
  *            存储q程名称
  * @param parameters
  *            参数对象数组
  * @param os
  *            输出参数对象数组
  * @return 输出参数对象数组
  * @throws Exception
  */
 public Object[] executeProcedureUpdate(String procName, Object[] parameters)
   throws Exception {
  logger.info("------------------------------------------------------------------------------------------------------");
  logger.info(" Run --> executeProcedureUpdate ##############   正在执行 存储q程: " + procName +"   ##############");
  CallableStatement cs = null;
  Object []returnVal = null;
  try {
  // 获取 存储q程 调用全名
  String fullPCallName = getProcedureCallName(procName,parameters.length);
  logger.info(" Run --> executeProcedureUpdate #   存储q程命o: " + fullPCallName +"   #");
  //获取存储q程参数信息
  ArrayList<HashMap<Object, Object>> p_Call_Info_List = getProcedureInfo(procName);
  //获取q接
  getConnection();
  //创徏 存储q程 执行对象
  cs = con.prepareCall(fullPCallName);
  //数组下标
  int index = 1;
  //输出参数下标 U录
        ArrayList<Integer> outPutIndexList = new ArrayList<Integer>();
        logger.info(" Run --> executeProcedureUpdate #   参数个数? " + parameters.length +"   #");
  for(HashMap<Object,Object> tempHash:p_Call_Info_List)
  {
   if("0".equals(tempHash.get("WAY")))
      {
    //讄输入参数
    cs.setObject(index, parameters[index-1]);
    logger.info(" Run --> executeProcedureUpdate #   输入 Input: ~号:" + index +" ? "+parameters[index-1]+" cd: "+parameters[index-1].getClass()+"   #");
   }
   else
   {
    //注册输出参数
    cs.registerOutParameter(index, getDataType(tempHash.get("TYPENAME").toString()));
    //U录输出参数的下?br />     outPutIndexList.add(index);
    logger.info(" Run --> executeProcedureUpdate #   输出 OutPut: ~号:" + index +" ? "+parameters[index-1]+" cd: "+parameters[index-1].getClass()+"   #");
   }
   index++;
  }
  logger.info(" Run --> executeProcedureUpdate #   参数讄完毕,正在执行?... :   #");
  
  //-------------------- 执行 -----------------
  if(!cs.execute())
  {
   returnVal = new Object[outPutIndexList.size()];
   logger.info(" Run --> executeProcedureUpdate #   执行成功! :   #");
   //取输 出参数的 q回?br />    for(int i = 0 ;i<outPutIndexList.size();i++)
   {
    returnVal[i] = cs.getObject(outPutIndexList.get(i));
    logger.info(" Run --> executeProcedureUpdate #   q回?"+(i+1)+" "+returnVal[i]+"   #");
   }
   con.commit();//提交
  }
  } catch (Exception e) {
   logger.info(" Run --> executeProcedureUpdate #   执行p|!事务回滚?.. :   #");
   con.rollback();
   throw e;
  }
  logger.info("------------------------------------------------------------------------------------------------------");
  return returnVal;
 }

 /** ****************************************************************************************** */
 /**
  * ********************************* 工?br />   * ************************************************
  */
 /** ****************************************************************************************** */

 /**
  * 关闭数据对象
  */
 public void close_DB_Object() {
  logger.info("###############close:::::关闭q接对象Q语句对象,记录集对?);
  if (null != rs) {
   try {
    rs.close();
   } catch (SQLException ex) {
    rs = null;
   }
  }
  if (null != stmt) {
   try {
    stmt.close();
   } catch (SQLException ex) {
    stmt = null;
   }
  }
  if (null != pstmt) {
   try {
    pstmt.close();
   } catch (SQLException ex) {
    pstmt = null;
   }
  }
  if (con != null) {
   dcm.freeConnection("mysql", con);
  }
 }


 /**
  * 讄Sql 指o参数
  *
  * @param p_stmt
  *            PreparedStatement
  * @param pramets
  *            HashMap
  */
 private PreparedStatement setParamet(PreparedStatement p_stmt,
   HashMap<Integer, Object> pramets) throws ClassNotFoundException,
   SQLException {
  // 如果参数为空
  if (null != pramets) {
   // 如果参数个数?
   if (0 <= pramets.size()) {
    for (int i = 1; i <= pramets.size(); i++) {
     try {
      // 字符cd String
      if (pramets.get(i).getClass() == Class
        .forName("java.lang.String")) {
       p_stmt.setString(i, pramets.get(i).toString());
      }
      // 日期cd Date
      if (pramets.get(i).getClass() == Class
        .forName("java.sql.Date")) {
       p_stmt.setDate(i, java.sql.Date.valueOf(pramets
         .get(i).toString()));
      }
      // 布尔cd Boolean
      if (pramets.get(i).getClass() == Class
        .forName("java.lang.Boolean")) {
       p_stmt.setBoolean(i, (Boolean) (pramets.get(i)));
      }
      // 整型 int
      if (pramets.get(i).getClass() == Class
        .forName("java.lang.Integer")) {
       p_stmt.setInt(i, (Integer) pramets.get(i));
      }
      // 点 float
      if (pramets.get(i).getClass() == Class
        .forName("java.lang.Float")) {
       p_stmt.setFloat(i, (Float) pramets.get(i));
      }
      // 双精度型 double
      if (pramets.get(i).getClass() == Class
        .forName("java.lang.Double")) {
       p_stmt.setDouble(i, (Double) pramets.get(i));
      }

     } catch (ClassNotFoundException ex) {
      throw ex;
     } catch (SQLException ex) {
      throw ex;
     }
    }
   }
  }
  return p_stmt;
 }

 /**
  * 转换记录集对象ؓ数组列表对象
  *
  * @param rs
  *            U录集合对象
  * @return 数组列表对象
  * @throws Exception
  */
 private ArrayList<HashMap<Object, Object>> convertResultSetToArrayList(
   ResultSet rs) throws Exception {
  logger.info("###############::转换记录集对象ؓ数组列表对象");
  // 获取rs 集合信息对象
  ResultSetMetaData rsmd = rs.getMetaData();
  // 创徏数组列表集合对象
  ArrayList<HashMap<Object, Object>> tempList = new ArrayList<HashMap<Object, Object>>();
  HashMap<Object, Object> tempHash = null;
  // 填充数组列表集合
  while (rs.next()) {
   // 创徏键值对集合对象
   tempHash = new HashMap<Object, Object>();
   for (int i = 0; i < rsmd.getColumnCount(); i++) {
    // 遍历每列数据Q以键值Ş式存在对象tempHash?br />     tempHash.put(rsmd.getColumnName(i + 1).toUpperCase(), rs
      .getString(rsmd.getColumnName(i + 1)));
   }
   // W一个键值对Q存储在tempList列表集合对象?br />    tempList.add(tempHash);
  }
  close_DB_Object();// 关闭相关链接
  return tempList;// q回填充完毕的数l列表集合对?br />  }

 /**
  * 从数据库得到存储q程信息
  *
  * @param procName
  *            存储q程名称
  * @return 数组列表对象
  * @throws Exception
  */
 private ArrayList<HashMap<Object, Object>> getProcedureInfo(String procName)
   throws Exception {
  return this.executeSql("select Syscolumns.isoutparam as Way,systypes.name as TypeName from sysobjects,syscolumns,systypes where systypes.xtype=syscolumns.xtype and syscolumns.id=sysobjects.id and sysobjects.name='"
    + procName + "' order by Syscolumns.isoutparam");
 }

 /**
  * 从数据库得到存储q程参数个数
  *
  * @param procName
  *            存储q程名称
  * @return 数组列表对象
  * @throws Exception
  */
 @SuppressWarnings("unused")
 private int getParametersCount(String procName) throws Exception {
  int returnVal = 0;
  for (HashMap<Object, Object> tempHas : this
    .executeSql("select count(*) as RowsCount from sysobjects,syscolumns,systypes where systypes.xtype=syscolumns.xtype and syscolumns.id=sysobjects.id and sysobjects.name='"
      + procName + "'")) {
   returnVal = Integer.parseInt(tempHas.get("ROWSCOUNT").toString());
  }
  return returnVal;
 }

 /**
  * 得到调用存储q程的全?br />   *
  * @param procName
  *            存储q程名称
  * @return 调用存储q程的全?br />   * @throws Exception
  */
 private String getProcedureCallName(String procName, int prametCount)
   throws Exception {
  String procedureCallName = "{call " + procName;
  for (int i = 0; i < prametCount; i++) {
   if (0 == i) {
    procedureCallName = procedureCallName + "(?";
   }
   if (0 != i) {
    procedureCallName = procedureCallName + ",?";
   }
  }
  procedureCallName = procedureCallName + ")}";
  return procedureCallName;
 }

 /**
  * 得到数据cd的整型?br />   *
  * @param typeName
  *            cd名称
  * @return 数据cd的整型?br />   */
 private int getDataType(String typeName) {
  if (typeName.equals("varchar"))
   return Types.VARCHAR;
  if (typeName.equals("int"))
   return Types.INTEGER;
  if (typeName.equals("bit"))
   return Types.BIT;
  if (typeName.equals("float"))
   return Types.FLOAT;
  return 0;
 }

 // 讄驱动路径
 @SuppressWarnings("static-access")
 public void set_DRIVER(String _DRIVER) {
  this._DRIVER = _DRIVER;
 }

 // 讄数据库密?br />  @SuppressWarnings("static-access")
 public void set_PASSWORD(String _PASSWORD) {
  this._PASSWORD = _PASSWORD;
 }

 // 讄数据库连接字W串
 @SuppressWarnings("static-access")
 public void set_URL(String _URL) {
  this._URL = _URL;
 }

 // 讄数据库用户名
 @SuppressWarnings("static-access")
 public void set_USER_NA(String _USER_NA) {
  this._USER_NA = _USER_NA;
 }

}



Sky Yi 2008-09-03 17:19 发表评论
]]>
վ֩ģ壺 ĺ| | | ˮ| | Ϫ| պ| | | | | Դ| | | | | ˳| ʩ| | ˮ| «| ϼ| ۩| ĺ| | | ʯ| | | Ű| Դ| | ɽ| ϰ| ̽| Ǭ| ٳ| | ̫| | ɶ|