Tuesday, August 13, 2019

single check box check at a time in a af:table

public void singleChk(ValueChangeEvent vce){
        vce.getComponent().processUpdates(FacesContext.getCurrentInstance());  
        
        DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        // Get an object representing the table and what may be selected within it
        DCIteratorBinding dcItteratorBindings1 = bindings.findIteratorBinding("DepartmentsVO1Iterator");
        // FacesContext context = FacesContext.getCurrentInstance();
        BindingContext bindingContext = BindingContext.getCurrent();
        DCDataControl dc =
            bindingContext.findDataControl("AppAMModuleDataControl"); // Name of application module in datacontrolBinding.cpx
        AppAMModuleImpl appM = (AppAMModuleImpl)dc.getDataProvider();
     
        ViewObject voTableData1= appM.findViewObject("DepartmentsVO1"); 
        Row currRow = voTableData1.getCurrentRow(); 
        Integer deptid = (Integer)currRow.getAttribute("DepartmentId");
        Row r[] = voTableData1.getFilteredRows("TSelect", "Y");
       if(r.length>0){
        for(Row rselect : r){
            Integer deptidSelect = (Integer)rselect.getAttribute("DepartmentId");
            if(deptid!=deptidSelect){
                rselect.setAttribute("TSelect", "N");
            }
        }
}
        
        AdfFacesContext.getCurrentInstance().addPartialTarget(sbc1);  
        AdfFacesContext.getCurrentInstance().addPartialTarget(t1);
    }



-------------------------------
below one failing in few cases
public void chk_vc(ValueChangeEvent vce) {
     
     
        try{
        vce.getComponent().processUpdates(FacesContext.getCurrentInstance());
          ViewObject vo=  ReusableMethodsClassCredit.getAM().findViewObject("WriteoffReviewDtlVO1");
          Row r1=  ReusableMethodsClassCredit.getCurrentRowFromVO("WriteoffReviewDtlVO1");
   
        String chk = (String)r1.getAttribute("TselectALLNONE");
            System.out.println(" r1 chk "+chk);
        if ("Y".equals(chk)) {
       
            int cnt = vo.getRowCount();
            System.out.println("current row count "+cnt);
            Row r = null;
            for (int i = 1; i <= cnt; i++) {
                if (i == 1) {
                    System.out.println("going to first ");
                    r = vo.first();
                  //  System.out.println("going to first "+r.getAttribute("AcctNo"));
                } else {
                    System.out.println("going to next ");
                    r = vo.next();
                 //   System.out.println("going to next "+r.getAttribute("AcctNo"));
                }
           
                r.setAttribute("TselectALLNONE", "N");
               // System.out.println("---note gen afterset --TselectPend- r-" + r.getAttribute("TselectPend")+r.getAttribute("AcctNo"));
                RichSelectBooleanCheckbox box =this.getSbc1();
               // box.setValue("N");
            }
            r1.setAttribute("TselectALLNONE", "Y");
         //   System.out.println("---note gen afterset --TselectPend- r1-" + r1.getAttribute("TselectPend")+r1.getAttribute("AcctNo"));
         
           AdfFacesContext.getCurrentInstance().addPartialTarget(sbc5);
            AdfFacesContext.getCurrentInstance().addPartialTarget(t1);
        }
        }catch (Exception e) {
                BindingContext bctx = BindingContext.getCurrent();
                ((DCBindingContainer)bctx.getCurrentBindingsEntry()).reportException(e);
         
        }
    }

No comments:

Post a Comment