package xin.glue.ui.B.B02; import com.posdata.glue.biz.activity.PosActivity; import com.posdata.glue.biz.constants.PosBizControlConstants; import com.posdata.glue.context.PosContext; import com.posdata.glue.dao.PosGenericDao; import com.posdata.glue.dao.vo.PosParameter; import com.posdata.glue.dao.vo.PosRowSet; public class PosInitParam extends PosActivity { //@Override public String runActivity(PosContext ctx) { /* * InitParam 传入参数说明: * 1. class: 类名(com.xin.ui.PosInitParam) * 2. dao : dao 名(mesdao) 3. sqlkey-count: sqlkey 数量 4. sqlkey 命名规则:'sqlkey' + 序号(0, 1, ...),如 sqlkey0, sqlkey1, ... 5. sqlkey 参数规则: 1) 参数数量命名规则:'sqlkey' + 序号 + '-param-count' 2) 参数命名规则 :'sqlkey' + 序号 + '-param + 参数序号 6. resultkey:返回结果集前缀 1) 结果集命名规则:resultkey + '_' + 序号,如: resultkey 设置为 ListResult,返回结果集为 ListResult_0, ListResult_1, ... 7. ServiceTag: 当且仅当执行 'success' 事件时,进行初始化 */ if (ctx.get("success") == null) // ServiceTag: success return PosBizControlConstants.SUCCESS; PosGenericDao dao = getDao(getProperty("dao")); String sqlkeyCt = getProperty("sqlkey-count"); if (sqlkeyCt == null) return PosBizControlConstants.SUCCESS; int count = Integer.parseInt(sqlkeyCt.trim()); if (count == 0) return PosBizControlConstants.SUCCESS; String resultkey = getProperty("resultkey"); System.out.println(resultkey); String[] sqlkey = new String[count]; for(int i = 0; i < count; i++) { sqlkey[i] = getProperty("sqlkey" + i); String paramCt = getProperty("sqlkey" + i + "-param-count"); String param[] = null; PosParameter posparameter = new PosParameter(); if (paramCt != null) { int cnt = Integer.parseInt(paramCt.trim()); param = new String[cnt]; for (int j = 0; j < cnt; j++) { param[j] = getProperty("sqlkey" + i + "-param" + j); Object obj = ctx.get(param[j]); if(obj instanceof String[]) posparameter.setWhereClauseParameter(j, ((String[])obj)[0]); else posparameter.setWhereClauseParameter(j, obj); } } PosRowSet posrowset = dao.find(sqlkey[i], posparameter); //ctx.setRowSet(resultkey + "_" + i, posrowset); ctx.put(resultkey + "_" + i, posrowset); } return PosBizControlConstants.SUCCESS; } }