Tuesday, October 1, 2013

How to select the rows in af:table with checkBox?


How to select the row in af:table with checkBox?








    public String findSelectedRows() {
        ViewObject vo = null;
        ApplicationModule am = null;
        am = getAMInstance("AppModule");
        vo = am.findViewObject("EmployeesView1");
        Row[] selRowArr = vo.getFilteredRows("Selected", Boolean.TRUE); //Selected is the Transient(boolean) attribute under the VO
        System.out.println(selRowArr.length+ "Row Selected");

        return null;
    }
 
    public static ApplicationModuleImpl getAMInstance(String AM) {
           
                FacesContext fc = FacesContext.getCurrentInstance();
                Application app = fc.getApplication();
                ExpressionFactory elFactory = app.getExpressionFactory();
                ELContext elContext = fc.getELContext();
                ValueExpression valueExp =
                    elFactory.createValueExpression(elContext, "#{data."+AM+"DataControl.dataProvider}",
                                                    Object.class);

                return (ApplicationModuleImpl)valueExp.getValue(elContext);
         
        }