c2b38e9fd62e067c690bcf6205e016036502894c.svn-base 2.9 KB

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