/** * * 扫描报到证号执行方法 */ public void bdzAction(ClientEvent clientEvent) { /** * Bindings做法步骤 * 1 根据bdzh内存查询 * 2 使用ADFUtils.setBoundAttributeValue("") * 3 执行Commit方法: ADFUtils.executeByOperation("Commit") */ //业务层操作,不推荐,因为UI-Bindings-BC,这三层关系,操作BC层结果不一定会响应到UI,操作Bindings会立刻响应到UI层 // DCIteratorBinding dcBinding = ADFUtils.findIterator("JyglBdzView1Iterator"); // JyglBdzViewImpl vo = (JyglBdzViewImpl) dcBinding.getViewObject(); // // String bdzh = (String) JSFUtils.getElExpression("#{bdzrkBean.bdzh}"); // String bdzh = (String) clientEvent.getParameters().get("bdzValue"); // String yhbh = UserOperation.getYhbh(); // vo.setWhereClause("Bdzh = '" + bdzh + "'"); // vo.executeQuery(); // if (vo.getEstimatedRowCount() > 0) { // Row row = vo.first(); // row.setAttribute("Rkr", yhbh); // row.setAttribute("Rksj", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // row.setAttribute("Bdzzt", 1); // vo.getDBTransaction().commit(); // } else { // JSFUtils.addFacesInformationMessage("不存在该报到证"); // } // vo.setWhereClause(null); // this.setBdzh(""); // ADFUtils.refreshTable("JyglBdzView1Iterator", (RichTable) JSFUtils.findComponentInRoot("t2"));//运行时有错,第二个参数改成this.getRichTable() // ADFUtils.refresh(JSFUtils.findComponentInRoot("it1")); //绑定层操作,优先推荐,内存查询可用ViewCriteria(有公共封装类调用,初学最好暂时不调用,自己写),setWhereClause(本身是数据库查询的,但是setQueryMode可设内存查), RowMatch查询 //优先使用ViewCriteria,这种查询方式不会影响到原来的结果集 String bdzh = this.getBdzh(); String yhbh = UserOperation.getYhbh(); System.out.println("报到证:" + bdzh); DCIteratorBinding dcBinding = ADFUtils.findIterator("JyglBdzView1Iterator"); JyglBdzViewImpl vo = (JyglBdzViewImpl) dcBinding.getViewObject(); //1,ViewCtriteria查询 ViewCriteria vc = vo.createViewCriteria(); vc.setName("criteria"); ViewCriteriaRow vcRow = vc.createViewCriteriaRow(); ViewCriteriaItem item = vcRow.ensureCriteriaItem("Bdzh"); item.setOperator("="); item.setValue(bdzh); vc.add(vcRow); vo.applyViewCriteria(vc); vo.executeQuery(); vo.findByViewCriteria(vc, -1, ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS); if (vo.getEstimatedRowCount() > 0) { ADFUtils.setBoundAttributeValue("Rkr", yhbh); ADFUtils.setBoundAttributeValue("Rksj", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); ADFUtils.setBoundAttributeValue("Bdzzt", 1); ADFUtils.executeByOperation("Commit"); } else { JSFUtils.addFacesInformationMessage("不存在该报到证"); } vo.removeViewCriteria("criteria"); //2,setWhereClause查询(有问题:页面列表结果只显示EO单表内容,VO是多表关联的话,其他表的字段值没有显示) // vo.setWhereClause("Bdzh = '" + bdzh + "'"); // vo.setQueryMode(ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS); // vo.executeQuery(); // if (vo.getEstimatedRowCount() > 0) { // ADFUtils.setBoundAttributeValue("Rkr", yhbh); // ADFUtils.setBoundAttributeValue("Rksj", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // ADFUtils.setBoundAttributeValue("Bdzzt", 1); // ADFUtils.executeByOperation("Commit"); // } // vo.setWhereClause(null); //3,RowMatch查询,只查询内存(也存在问题,和setWhereClause一样) // RowMatch rm = new RowMatch("Bdzh = '" + bdzh + "'"); // vo.setRowMatch(rm); // vo.setQueryMode(ViewObject.QUERY_MODE_SCAN_ENTITY_ROWS); // vo.executeQuery(); // if (vo.getEstimatedRowCount() > 0) { // ADFUtils.setBoundAttributeValue("Rkr", yhbh); // ADFUtils.setBoundAttributeValue("Rksj", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // ADFUtils.setBoundAttributeValue("Bdzzt", 1); // ADFUtils.executeByOperation("Commit"); // } // vo.setRowMatch(null); System.out.println(vo.getQuery()); this.setBdzh(""); ADFUtils.refreshTable("JyglBdzView1Iterator", this.getRichTable()); ADFUtils.refresh(JSFUtils.findComponentInRoot("it1")); }