a8b0ecb351f46cb69ff8144c31a92c98a0931bee.svn-base 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package xin.glue.ui.B.B01;
  2. import com.posdata.glue.biz.activity.PosActivity;
  3. import com.posdata.glue.biz.constants.PosBizControlConstants;
  4. import com.posdata.glue.context.PosContext;
  5. import com.posdata.glue.dao.PosDaoException;
  6. import com.posdata.glue.dao.PosGenericDao;
  7. import com.posdata.glue.dao.vo.PosParameter;
  8. import com.posdata.glue.dao.vo.PosRowSet;
  9. /**
  10. *
  11. * @Description 页面初始化
  12. * @author 梅贵平{meiguiping}
  13. * @date 2008-10-30 下午08:42:42
  14. * @JDK Version jdk1.4.2
  15. */
  16. public class InitParamManager extends PosActivity
  17. {
  18. public InitParamManager(){}
  19. public String runActivity(PosContext context)
  20. {
  21. try
  22. {
  23. if(context.get("success")==null)//若触发的非success事件,则不进行初始化查询
  24. {
  25. return PosBizControlConstants.SUCCESS;
  26. }
  27. String sCount = this.getProperty("param-count");
  28. //判断页面是否需要初始化
  29. if(sCount != null)
  30. {
  31. PosGenericDao posDao = this.getDao(this.getProperty("dao"));//获得数据访问对象
  32. String[] rkl = (String[])context.get("ResultKeyList");
  33. int rklLength = 0;
  34. if(rkl !=null)
  35. {
  36. rklLength = rkl.length;
  37. }
  38. int iCount = Integer.parseInt(sCount.trim());//获取所对应的sql语句的个数
  39. String[] arrSql = new String[iCount];//定义存放sqllist的数组
  40. String[] nodeList = new String[iCount];//定义存放各sql语句参数的数组
  41. int arrCount = iCount+rklLength;
  42. String[] arr = new String[arrCount];//各查询结果对象(PosRowSet)放入该数组, arr将存放到ResultKeyList中
  43. String[] initResult = this.getProperty("initResult").split("\\|");//分割resultkey
  44. //循环中存放参数及执行相应的SQL语句
  45. for(int i=0; i < iCount; i++)
  46. {
  47. PosParameter posParam = new PosParameter();
  48. arrSql[i] = this.getProperty("sqlkey"+i);//获得各条sql语句
  49. nodeList[i] = this.getProperty("param"+i);//获得各条sql语句的参数 如:"ID|NAME|CHARGE_NO|XIN_DATE"
  50. arr[i] = initResult[i]; //获得各具体的PosRowSet存放对象,如:EmpListResult
  51. if(nodeList[i] !=null && !"NULL".equalsIgnoreCase(String.valueOf(nodeList[i])))
  52. {
  53. String[] nodeName = nodeList[i].split("\\|");//获取各个具体的参数,即节点名称
  54. //sql预处理
  55. for(int j=0; j < nodeName.length; j++)
  56. {
  57. posParam.setWhereClauseParameter(j, ((String[])context.get(nodeName[j]))[0]);
  58. }
  59. }//if(isNull) end
  60. PosRowSet rowset = posDao.find(arrSql[i], posParam);
  61. context.put(arr[i], rowset);//将结果集放入相应的resultkey中
  62. }//for(iCount) end
  63. if(rkl!=null)
  64. {
  65. System.arraycopy(rkl, 0, arr, iCount, rklLength);//数组copy 将initResult初始化结果集也放到ResultKeyList中
  66. }//if(rkl) end
  67. context.put("ResultKeyList", arr);
  68. }//if(sCount)end
  69. }
  70. catch(Exception e)
  71. {
  72. throw new PosDaoException((new StringBuffer(400).append("Parameters initialize failed. detailMessage = ")).append(e.toString()).toString() , e);
  73. }
  74. return PosBizControlConstants.SUCCESS;
  75. }
  76. }