/** * 将全部记录加入列表 */ public void buildRecordsList() { try { getMySession(); recordsList = new ArrayList<BallotItems>(); Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); String hId = (String) params.get("headerId"); if (!FunctionLib.isNum(hId)) hId = getMySession().getTempStr().get("BallotItems.headerId"); if (FunctionLib.isNum(hId)) { getMySession().getTempStr().put("BallotItems.headerId", hId); Query query = getSession().getNamedQuery("core.ballot.items.records"); query.setParameter("headerId", hId); Iterator<?> it = query.list().iterator(); int id, cId, mId; String cDate, mDate, uuid; String t; int o; String hasOp = "false"; while (it.hasNext()) { Object obj[] = (Object[]) it.next(); id = cId = mId = 0; cDate = mDate = uuid = ""; t = ""; o = 0; id = FunctionLib.getInt(obj[0]); cId = FunctionLib.getInt(obj[1]); cDate = FunctionLib.getDateTimeString(obj[2]); mId = FunctionLib.getInt(obj[3]); mDate = FunctionLib.getDateTimeString(obj[4]); t = FunctionLib.getString(obj[7]); o = FunctionLib.getInt(obj[8]); recordsList.add(new BallotItems(id, cId, cDate, mId, mDate, uuid, Integer.valueOf(hId), t, o, FunctionLib.getString(obj[9]))); if (mId == getMySession().getUserId() && o == 0) hasOp = "true"; } it = null; getMySession().getTempStr().put("BallotItems.hasOp", hasOp); } } catch (Exception ex) { ex.printStackTrace(); } }
/** * 读取一条记录 */ public void selectRecordById() { try { Map<?, ?> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); String id = (String) params.get("id"); Query query = getSession().getNamedQuery("core.ballot.items.getrecordbyid"); query.setParameter("id", id); Iterator<?> it = query.list().iterator(); while (it.hasNext()) { this.reset(); Object obj[] = (Object[]) it.next(); ID_ = FunctionLib.getInt(obj[0]); CID_ = FunctionLib.getInt(obj[1]); CDATE = FunctionLib.getDateTimeString(obj[2]); MID_ = FunctionLib.getInt(obj[3]); MDATE = FunctionLib.getDateTimeString(obj[4]); headerId = FunctionLib.getInt(obj[6]); title = FunctionLib.getString(obj[7]); orderNum = FunctionLib.getInt(obj[8]); } it = null; } catch (Exception ex) { ex.printStackTrace(); } }